#include<iostream.h.h> #include<conio.h> //---------------------------- distance -------------------------------// class distance { private: int feet; float inches; public: distance() { feet=0,inches=0; } distance(int ft,float inch) { feet=ft,inches=inch; } distance operator +(distance); void getdist(); void showdata (){cout << feet <<\" f - \"<<inches<<\'\"\'<<endl;} }; //--------------------------- getdist( ) ------------------------------// void distance::getdist() { cout<<\"Enter the feet = \"; cin>>feet; cout<<\"Enter the inches = \"; cin>>inches; } //------------------------- operator+(distance) -----------------------// distance distance::operator+(distance d1) { distance r; r.feet = d1.feet+feet; r.inches =d1.inches+inches; if(r.inches >=12.0) { r.inches-=12.0; r.feet++; } return r; } main( ) { clrscr(); distance dist1,dist2(11, 6.25),dist3,dist4; dist1.getdist(); dist3=dist1+dist2; dist4=dist1+dist2+dist3; cout<<\"dist1 = \"; dist1.showdata(); cout<<\"dist2 = \"; dist2.showdata(); cout<<\"dist3 = \"; dist3.showdata(); cout<<\"dist4 = \"; dist4.showdata(); getch(); return 0; }