This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Constructor for new T[..]
- From: Andrei Zmievski <andrei at gravitonic dot com>
- To: gcc at gnu dot org
- Date: Tue, 6 May 2003 13:22:31 -0400
- Subject: Constructor for new T[..]
I found out that it's possible to invoke a non-default constructor when
using 'new' operator to create an array of objects.
class Fred {
public:
Fred() { cout << "default" << endl; }
Fred(int i, int j) { cout << i << ", " << j << endl; }
};
int main()
{
Fred *f = new Fred[2](2, 5);
}
None of the sources I've seen say that this is legal. Is this a GCC
extension?
-Andrei http://www.gravitonic.com/