How to create array of class without default constructor

Hi...
I am C++ beginner and would like to know how to create array of class without default constructor.

Class myClass {
public :
myClass (int a, int b);
myClass (double a, double b);
private :
int ia;
int ib;
}

I want to create, say 100 array, which parameter can be from a loop.

myClass myC[100];

so,
myC [0] --> a=0 b=0
myC [1] --> a=1 b=1
That is.

Thank you,

Abu



You can't.

The declaration myClass myC[100]; implies that myClass has a default constructor.
Thinking further, if you had a collection of pointers to myClass, you can make them up however you like and insert them.

1
2
3
4
5
6
7
typedef myClass* PtrMyClass;

PtrMyClass myC[100];

myC[0] = new myClass(0, 0);
myC[1] = new myClass(1.5, 3.14);
//... 
Thanks for the answer.

Abu
Topic archived. No new replies allowed.