I am working on a programm which has two lists. One of the list stores objects. The other list stores pointers to items of the list containing the objects. When a new item is added to the object list I want to get the pointer to the object. But I always get the same pointer returned.
Since my program is to big now I made a new, smaller one to show you the problem:
using namespace std;
std::list<class C_Test> Testlist;
C_Test * p = &*Testlist.end();
cout << p << endl;
p = &*Testlist.end();
cout << p;
For starters dereferencing the iterator returned by the member function
end has undefined behavior.
I think you mean
C_Test * p = &Testlist.back();