I have a ObjectA. ObjectB and ObjectC.
ObjectB creates instances of objectC
ObjectB(){my_objectC = new ObjectC)
ObjectA creates instances of ObjectB and I'd want to save individual objectC instances inside a vector:
ObjectA:
1 2 3 4 5 6
|
myvector<*objectC> my_c_instances_vector;
for (int x=0;x<10;x++; )
{
object_b = new ObjectB; // line 1
call object_b some methods; // line 2
my_c_instances_vector.push_back(object_b->my_objectC);
|
}
I have some important errors related (I suposse) with construction &
destruction.
I'm saving pointers of objectsC inside my vector , ins't it?
What happens with "object_b->my_objectC" added to the vector when I create a new object_b at line 1?? Or : how can surely I add objects to my vector ?.
And... can I add objects by pointer from volatile objects ?
That is to say :
I have inside a function :
ObjectB temp_objectB;
Can I add myobjectB.objectC?
Have I to write:?
ObjectB * temp_objectB = new ObjectB
And another question, what is the life of object created 'as new' inside a function ?
By last, when I end the procces have I to delete every object of the vector manually ? How ? Assigning every vector member to a object, pop_backing and deleting the object ?
Any idea ? I need help...
Thanks