Question: Instructions: Do not write full class. Just write the required code for Part - a and Part - b. Also dry run the code on
Instructions: Do not write full class. Just write the required code for Part - a and Part - b. Also dry run the code on the given data. If there are errors in the code, correct them (also highlight them using some other ink pen or by underlining).
class Distance //English Distance class { int feet; float inches; public: //constructor (no args) Distance(): feet(0), inches(0.0) { } //constructor (two args) Distance(int ft, float in) : feet(ft), inches(in){} void getdist() //get length from user { cout << Enter feet: ; cin >> feet; cout << Enter inches: ; cin >> inches; } void showdist() const //display distance { cout << feet << \- << inches << \; } }; a). Overload the += operator so that the following code works. Distance d1(3,7), d2(1,3); d2 += d1; b). Overload the > operator so that the following code works. Distance d1(3,7), d2(1,3); if (d2 > d1) cout <
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
