August 2012
Intermediate to advanced
976 pages
30h 17m
English
Ordinarily, classes in C++ define the equality operator to test whether two objects are equivalent. That is, they usually compare every data member and treat two objects as equal if and only if all the corresponding members are equal. In line with this design philosophy, our Sales_data equality operator should compare the bookNo as well as the sales figures:
bool operator==(const Sales_data &lhs, const Sales_data &rhs){ return lhs.isbn() == rhs.isbn() && lhs.units_sold == rhs.units_sold && lhs.revenue == rhs.revenue;}bool operator!=(const Sales_data &lhs, const Sales_data &rhs){ return !(lhs ...
Read now
Unlock full access