Untitled
unknown
plain_text
a year ago
647 B
8
Indexable
#include<iostream>
using namespace std;
class DIST
{
public:
int feet, inch;
DIST()
{
this -> feet = 0;
this -> inch = 0;
}
DIST (int f, int i)
{
this -> feet = f;
this -> inch = i;
}
DIST operator + (DIST d2)
{
int ft = feet + d2.feet;
int in = inch + d2.inch;
ft = ft + in/12;
in = in%12;
return DIST(ft,in);
}
};
int main ()
{
DIST d1 (8,9);
DIST d2 (10,5);
DIST d3;
d3 = d1+d2;
cout<<"Total Feet and inches :"<< d3.feet<<"' "<< d3.inch <<"\"" << endl;
return 0;
}
Editor is loading...
Leave a Comment