Question: Okay. So I have declared an array of objects, and I have manually defined them using this code:

```
Object* objects[] =
{
    new Object(/*constructor parameters*/),
    new Object(/*constructor parameters*/)
}; 

```

Is there anyway to use some kind of a loop (preferably a for loop) to declare these? Something like:

```
Object* objects[] =
{
    for(int i=0; i<20; /*number of objects*/ i++)
    {
        new Object(/*constructor parameters*/);
    }
}; 

```

But with proper syntax?

Answer: 
I strongly suggest using a standard library container instead of arrays and pointers:

```
#include <vector>

std::vector<Object> objects;

// ...

void inside_some_function()
{
    objects.reserve(20);
    for (int i = 0; i < 20; ++i)
    {
        objects.push_back(Object( /* constructor parameters */ ));
    }
}

```

This provides exception-safety and less stress on the heap.
```
Object* objects[20];

for(int i=0; i<20; /*number of objects*/ i++)
{
    objects[i] = new Object(/*constructor parameters*/);
}

```