There is a Base class and a Derive class. Derive public inherit Base. The base class has implemented a friend function bool operator==(const Base& lhs,const Base& rhs) const;
I am implementing the Derive class, which also need to implement bool operator==(const Derive& lhs, const Derive& rhs) const; Now my problem is that I do not know how to call the parents’s operator== function in my operator== function. The operator== for Base class dose not belong to base, so i cannot simply use Base::operator==. Thank you.
There is a Base class and a Derive class. Derive public inherit Base. The
Share
Bind references to the
Basesubobjects, and compare them with normal operator syntax. An example:Warning: A setup like this will silently slice if you accidentally compare a
Baseto aDerive. If the base class must be comparable, it might be worth setting up a virtual comparison mechanism.