c++ vector inside a structure
I've got a doubt about using "vector". If I got a structure with a vector
object with nondefined space in the memory, if it need to be reallocate
(the vector), is the structure also reallocated? or only the vector?.
For example:
struct cluster{
int a;
int b;
struct cluster* parent;
vector<struct cluster> childs;
}
struct cluster obj = {2,1,...};
struct cluster *pobj = &obj;
for(int i = 0; i < 100 ; i ++){
childs.push_back(i); //The capacity will be increased progressly, no?
}
So, the question is: is pobj==&obj at the end of "for" loop? or obj is
reallocated because of the reallocation of childs vector object?
I hope I explained my doubt. Thanks for your time.
No comments:
Post a Comment