I dont think it is a good idea to handle adresses of objects inside a container, since inserting method and algorithm may invalidate them. Even if it would work with a list, it not a good reflex.
If you want to share data, you can use shared pointers.
For instance, using STL and boost :
//type definition
class C1{};
typedef boost::shared_ptr<C1> C1ShPtr;
//list declaration
std::list<C1ShPtr> A, B;
//creating and sharing a item in the 2 lists
C1ShPtr item(new C1);
A.push_back(item);
B.push_back(item);
//type definition
class C1{};
typedef boost::shared_ptr<C1> C1ShPtr;
//list declaration
std::list<C1ShPtr> A, B;
//creating and sharing a item in the 2 lists
C1ShPtr item(new C1);
A.push_back(item);
B.push_back(item);
To copy to clipboard, switch view to plain text mode
I let you convert this code with Qt containers to make this post to come back in Qt-related scope
Bookmarks