Overload the comparison (==) operator for the Airplane class below to compare th
ID: 3588922 • Letter: O
Question
Overload the comparison (==) operator for the Airplane class below to compare the model data member in the function template above to a specific value (i.e., Skylark). [Hint1: This comparison is not between two Airplane objects, but rather a comparison between an object’s data member and a value. Hint2: Consider using the compiler to verify the answer.] class Airplane { private: string make; // Cessna, Piper, etc. string model; // Skylark, Cub, etc. int topSpeed; public: void setMake(string mk); void setModel(string mdl); void setTopSpeed(int tspd); };
Explanation / Answer
bool Airplane::operator==(string rhs)const{
if (this->model.compare(rhs)==0)
return true;
return false;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.