Lets say you are creating an array of objectes on the heap like so:
myClass * objectPtr = new myClass[10];
new
only invokes the default constructor, and (based on my readings) does not allow any other constructor to be invoked.
Is there any logic behind why new
cannot invoke any other constructor? It would seem better to do something like
myClass * objectPtr = new myClass[10](12);
as opposed to
myClass * objectPtr = new myClass[10];
objectPtr[0] = myClass(12);
objectPtr[1] = myClass(12);
...