C++ (Qt)typedef long long TID;class MyObjectID {public: MyObjectID( void ) { mID = ++theGobalID; theGlobalMap[mID] = this; } virtual ~MyObjectID( void ) { TMapID::iterator it = theGlobalMap.find(mID); if (it != theGlobalMap.end()) it->second = 0; } static MyObjectID * GetByID( TID ID ) { TMapID::iterator it = theGlobalMap.find(ID); return (it == theGlobalMap.end()) ? 0 : it->second; } private; TID mID; static TID theGlobalID; typedef std::map <TID, MyObjectID *> TMapID; static TMapID theGlobalMap:}; // сериализацияQDataStream & QDataStream::operator << ( QDataStream & out, const MyObjectID & );QDataStream & QDataStream::operator >> ( QDataStream & out, MyObjectID & );
C++ (Qt)struct A { B * mB; // A хранит указатель на B};
C++ (Qt)struct A { TID mB; // A хранит ID B};