Suppose I want to dynamically create a non-fixed number of a certain class of objects at runtime.
int i;
cin >> i;
MyClass * my_objects;
my_objects = new MyClass(<some parameter>)*;
This syntax is obviously wrong, according to my compiler. But you probably know what I’m trying to do. I want to create an array of i MyClass’es, each calling a constructor that has some parameter.
my_objects = new MyClass *; works, but I want to call a constructor other than the default constructor for each new object. How do I do this?