Question: C++ Operator Overloading Add the requested functionality to the Distance class below: class Distance { private: int feet; int inches; public: Distance(int inch) { feet
C++ Operator Overloading
Add the requested functionality to the Distance class below:
class Distance {
private:
int feet;
int inches;
public:
Distance(int inch) { feet = inch/12; inches = inch % 12; };
Distance(int f, int i) { feet=f; inches=i; };
//Overloaded + that will add two distance objects and return sum in a
//distance object
//Conversion function (to type int) that will return the distance in inches
//Overloaded pre-increment operator that adds 1 to inches
//Overloaded post-increment operator that adds 1 to inches
}; //end Distance
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
