Sorry for my English.
Some class:
class Kid {
public:
...
string _name;
std::list<string> _cuteKids;
};
Use class:
std::list<Kid> kids;
kids.push_back(new Kid("Jeck"));
kids.push_back(new Kid("Anna"));
kids.push_back(new Kid("Toma"));
for(auto e: kids) {
e._cuteKids.push_back("Jeck"); // Many some names...
[1]
}
[2]
If you look at the code in the debugger, the list in paragraph 1 _cuteKids - have item. But if look at the list in paragraph 2 _cuteKids - no have item. Why?
This is just an example, actually I much complicated algorithm, but the bottom line is that after a loop _cuteKids becomes empty. As if it is a static variable (e: kids), not a pointer to a variable of kids.