Hi There,
My code looks like:
Would you please let me know what needs to be done in order that the find could succeed? I tried to overload operator == but that was no help.Code:class CClassExample { int id1, id2, id3; public: CClassExample(int i1, int i2, int i3) { id1 = i1; id2 = i2; id3 = i3; } friend bool operator < (const key& left, const key& right) { if (left.id1 > right.id1) { return false; } return true; } }; typedef std::map<CClassExample, void*> TypeItems; static TypeItems Items; // Putting data into items using insert, it is fine size_t st = Items.size(); // It is correct CClassExample Exa(1, 2, 3); // There is an item having id1 == 1, id2 == 2, id3 ==3 TypeItems::interator it = Items.find(Exa); if (it == Items.end()) { // This happens }
Thanks![]()




Reply With Quote