Hello, a very simple question:
Ok I have a class MyClass with a constructor MyClass(int) (no constructor
without argument defined)
how can I make an array of pointers to objects of that class, calling the
constructor with the index number as argument?
<code>
int N = 22;
pointerArray = new MyClass*[N];
for (int i=0; i< N; i++)
pointerArray[i]->MyClass(i);
</code>
is this correct? does the second line call some default constructor for
MyClass? Any better idea how to do that?
Thanks Phil
Ok I have a class MyClass with a constructor MyClass(int) (no constructor
without argument defined)
how can I make an array of pointers to objects of that class, calling the
constructor with the index number as argument?
<code>
int N = 22;
pointerArray = new MyClass*[N];
for (int i=0; i< N; i++)
pointerArray[i]->MyClass(i);
</code>
is this correct? does the second line call some default constructor for
MyClass? Any better idea how to do that?
Thanks Phil
Comment