Using c++ programming language. Write a class Distance that holds distances or measurements expressed in feets and inches. This class has two private data members: feet: An integer that holds the feet. inches: An integer that holds the inches. 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. Generate appropriate getter-setter functions for the data members. o void setFeet(int f) and int getFeet()const o void setInches(int i) It should ensure proper conversion to feet. o int getInches() const Define an operator ‘+’ that overloads the standard ‘+’ math operator and allows one Distance object to be added to another. Distance operator+ (const Distance &obj). Define an operator - function that overloads the standard ‘-‘ math operator and allows subtracting one Distance object from another. Distance operator-(const Distance &obj) Define an operator= function that overloads the = operator and assign one Distance object to another. const Distance operator=(const Distance &obj)
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Using c++ programming language.
Write a class Distance that holds distances or measurements expressed in feets and inches. This
class has two private data members:
feet: An integer that holds the feet.
inches: An integer that holds the inches.
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.
Generate appropriate getter-setter functions for the data members.
o void setFeet(int f) and int getFeet()const
o void setInches(int i) It should ensure proper conversion to feet.
o int getInches() const
Define an operator ‘+’ that overloads the standard ‘+’ math operator and allows one
Distance object to be added to another. Distance operator+ (const Distance &obj).
Define an operator - function that overloads the standard ‘-‘ math operator and allows
subtracting one Distance object from another. Distance operator-(const Distance &obj)
Define an operator= function that overloads the = operator and assign one Distance object
to another. const Distance operator=(const Distance &obj)
Step by step
Solved in 3 steps with 1 images