Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
553 B
2
Indexable
Never
#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 d1) {
    int ft=feet + d1.feet;
    int in=inch + d1.inch;
    ft= ft + in/12;
    in= in%12;

    return dist(ft,in);


    }
};

int main() {
dist d2(5,6);
dist d1(10,5);
dist d3;

d3=d1+d2;
cout<<"Total Feet and Inches: "<<d3.feet<<"' "<<d3.inch<<"\""<<endl;

return 0;
}
Leave a Comment