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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started