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)
#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;
}
};
Comments
Leave a comment