I have a classA, it creates objectsB * (by pointer)
my_objectB = new ObjectB; ( inside classA)
my_objectB = new ObjectB; ( inside classA)
To copy to clipboard, switch view to plain text mode
And from the main, I want to add "objectsB" to a vector.
vector<objectC*> my_vector; (my vector is private for main )
vector<objectC*> my_vector; (my vector is private for main )
To copy to clipboard, switch view to plain text mode
So, I can write inside main_create():
for (int x=0;x<10;xx++)
{
ClassA class_a* = new ClassA;
my_vector.push_back(class_a->my_objectB)
}
for (int x=0;x<10;xx++)
{
ClassA class_a* = new ClassA;
my_vector.push_back(class_a->my_objectB)
}
To copy to clipboard, switch view to plain text mode
My doubt is ... Every time I create class_a, a new instance is created, and there is no re-write of class_a->my_objectB, ins't it ?
Ok. on main I have main_process, a function that are going to do thing with the vector. My question is , objectB instances inside the vector exist ? or maybe I have a risk of crash becasue thet were created by a temporal classA inside 'main_create'.
By last. I have to free every objectB instance inside the vector with pop_back ? Or need I to do more ?
Any tip ? Thanks.
Bookmarks