Wednesday, 18 September 2013

initializing pointer to array with two different constructor

initializing pointer to array with two different constructor

I have a program in which i want to initialize an array of class objects
using pointer.
class xyz{};
cin<<M;
xyz *a=new xyz[M]; //this will call the constructor for each object.
the problem is that i have two constructor in class xyz. i want to
initialize last two element using other constructor, not the default one
with no arguments. how can i do this?
i want M+1'th and M+2'th term to be initialized by different constructor
that accepts argument.

No comments:

Post a Comment