Assume that we have following class:
class Test {
public:
Test() {}
std::vector<int>& getIntList() {
return intList;
}
private:
std::vector<int> intList;
};
Also, we have following codes inside main function to declare class array:
int main(void) {
Test* test[20];
for (int i = 0; i < 20; ++i) {
test[i] = new Test();
}
}
In these cases, test objects are instantiated.
Now if I append multiple items in the vector inside each class randomly,
there might exist chances to collide memory address range of each vector inside each class while resizing their memory size.
In this case, is the entire 'test' object copied into other memory area and vector is resized? Or, is vector STL only copied into other memory area and resized while the class references the vector?
Entirely, is not a good idea to code like this?