Question: Write in C++ Write a class Distance that holds distances or measurements expressed in feet and inches. This class has two private data members: feet:

Write in C++ Write a class Distance that holds distances or measurements expressed in feet and inches. This class has two private data members: feet: An integer that holds the feet. inches: An integer that holds the inches. 2.1 Write a constructor with default parameters that initializes each data member of the class. If inches are greater than equal to 12 then they must be appropriately converted to corresponding feet 2.2 Generate appropriate getter-setter functions for the data members. bool setFeet(int f) int getFeet()const bool setInches(int i) It should ensure proper conversion to feet. int getInches()const 2.3 Define an operator + that overloads the standard + math operator and allows one Distance object to be added to another. Distance operator+ (const Distance &obj) 2.4 Define an operator- function that overloads the standard - math operator and allows subtracting one Distance object from another. Distance operator- (const Distance &obj) 2.5 Define an operator= function that overloads the = operator and assign one Distance object to another. const Distance operator= (const Distance &obj) 2.6 Write main function to test all the implemented functionality.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!