Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

class Distance { private: double meters; double centimeters; public: Distance (double m=1, double c=1) { meters = m; centimeters = c; } }; int main()

class Distance

{

private:

double meters;

double centimeters;

public:

Distance (double m=1, double c=1) {

meters = m;

centimeters = c; }

};

int main()

{

Distance d1(4,5), d2(2,3), d3;

}

- write setMeters and setCentimeters and let them havecascading capability.

They must be set to positive values.

-Overloadthe + operator to add two Distances and return the double sum of

all data members of both objects in centimeters.

( double sum = d1 + d2; //d1 and d2 are objects of class Distance)

-Overloadthe post-increment operator d2++; to increment by 1 the meter data member.

-Overload<< to print out a Distance using the following format:

Distance Information [2 Meters, 55.6 centimeters]

-Dynamically create an array of objects of class Distance in main and set their members

to values entered by the user.

You must do something before exiting the code

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

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago