void the_method_where_I_want_to_create_it()
{
for (int i=0;i<20;i++)
{
objects.push_back(a_objects(parameters,here));
}
}
Note that vectors store copies of the objects you pass to push_back.
When the objects is not copyable (or if it is not desirable), you can use ptr_vector:
1 2
extern boost::ptr_vector<a_object> objects;
//doesn't need to be the boost one, there are many implementations of ptr_vector
And the other line changes to: objects.push_back(new a_object(parameters,here));
It would probably be better to create a class that manages the set of objects instead of simply having a global, generic container. Depends on your situation, though.
Thanks
And, summarizing, is not posible to declare an array of objects (with or not with parameters at constructor) at h. file and give the dimension later ?