Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions