I want to create in C++ an array of Objects without using STL.
How can I do this?
How could I create array of Object2, which has no argumentless constructor
Use an array of pointers to Object2:
std::tr1::shared_ptr* newArray = new shared_ptr[numberOfObjects];
for(int i = 0; i < numberOfObjects; i++)
{
newArray[i] = shared_ptr(new Object2(params));
}
Or, alternatively, without the use of shared_ptr:
Object2** newArray = new Object2*[numberOfObjects];
for(int i = 0; i < numberOfObjects; i++)
{
newArray[i] = new Object2(params);
}