class Triad { private: int a, b, c; public: virtual bool operator == (const Triad &tf)noexcept { return ((a == tf.a) && (b == tf.b) && (c == tf.c)); } }; class Date : public Triad { private: int day; int month; int year; public: bool operator == (const Date &dt)noexcept override ^^^^^^^ { return ((day == dt.day) && (month == dt.month) && (year == dt.year)); } }; 
  • 2
    Take and recapture. Similar. Why did this question arise? - AnT
  • It does not work, because the type of the passed parameters is different. In the base I pass Triad and in the derived Date. Because of this, "a member function declared using the override keyword does not override a member of the base class" - ANurbaev
  • one
    And why is there any virtuality? as for me, two non-virtual operators are needed here - so that it is clear what is being compared with ... - Harry
  • If you are inheriting, you probably should use a , b , c from the base class, and not create new fields. Then operator== will not need to be overridden. - HolyBlackCat pm
  • one
    If you compare with Triad , then this is a completely different comparison than with Date . You can compare Date with both Triad and Date - but in different ways. Just enter the name in Date - using Triad::operator==; , well, I would make these operators constant. Well, and about inheritance - this is why you inherit Date from Triad for some reason, adding three more fields ... - Harry

0