12345678910111213141516171819202122232425
class car { public: car(int); int HorsePower; int getHorsepower(); car operator == (const car,car rhs){ if(this->lhs.getHorsepower() < rhs.getHorsepower()) { cout << "Too strong" << endl; } else cout << "too weak" << endl; } }; int car::getHorsepower() { return HorsePower; } car::car(int c) { HorsePower = c; }
12345678910111213141516
bool operator == (const car &rhs) { if(HorsePower < rhs.HorsePower) { cout << "Too strong" << endl; return false; } else if (HorsePower > rhs.HorsePower) { cout << "too weak" << endl; return false; } return true; }
operator==