Constructor for new T[..]
Andrei Zmievski
andrei@gravitonic.com
Tue May 6 17:23:00 GMT 2003
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/
More information about the Gcc
mailing list