Answer to Question #274611 in C++ for Amit

Question #274611

Create a class distance which stores a distance in feet and inches.Input 2 distance values in objects, add them, store the resultant distance in an object and display it.

[Write the above program in two ways.]

a) store the resultant distance in the calling object:C3.add(C1,C2)      

b) return the resultant object C3=C1.add(C2)



1
Expert's answer
2021-12-02T14:15:53-0500
#include <iostream>
#include <string>
using namespace std;


class Date
{
private:
    int distance1, distance2;
public:
    Date();
    Date(int distance1, int distance2) {
        this->distance1 = distance1;
        this->distance2 = distance2;
    }
    ~Date(){}
    int add(){
        return this->distance1 + this->distance2;
    }
};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment