Help me please.
“object.cpp”:
bool OBJECT::operator== (const OBJECT &object) const
{
return *this == object;
}
bool OBJECT::operator< (const OBJECT &object) const
{
return this->m_numberOfObject < object.m_numberOfObject;
}
“other_object.h”
class other_object{
...
set<OBJECT*>* m_imitatedObjects
... }
“other_object.cpp”
m_imitatedObjects.insert(pointer on some instance of class OBJECT) –
raises error in runtime, as I think due to cmp function wasn`t defined properly.
What to do, how can I fix this error?
This function calls itself, causing a stack overflow. You should replace this function with whatever logic you want to use to tell if the two objects are equivalent.
Also, unless every
OBJECThas a uniquem_numberOfObjectvalue, youroperator<does not create a strict ordering. (Because neither of two objects with the samem_numberOfObjectvalue but otherwise different will be less than the other.) This may cause yoursetto work differently from how you expect.