#include<iostream.h>
#include<conio.h>
class distance
{
int feet;
float inches;
public:
distance()
{
feet=0;
inches=0.0;
}
void getdist()
{
cout<<"\n Enter Feets ";
cin>>feet;
cout<<"\n Enter Inches ";
cin>>inches;
}
void showdist()
{
cout<<"\n Distance is "<<feet<<"-"<<inches;
}
distance operator+(distance);
};
distance distance::operator+(distance d)
{
distance temp;
temp.feet=feet+d.feet;
temp.inches=inches+d.inches;
return temp;
}
void main()
{
distance d1,d2,d3,d4,d5;
clrscr();
/////////////////
int a,b,c;
a=10;
b=20;
c=a+b;
cout<<"\n Sum is "<<c;
///////////////////////
d1.getdist();
d2.getdist();
d4.getdist();
d5.getdist();
d3=d1 + d2 + d4 + d5;
d3.showdist();
getch();
}
#include<conio.h>
class distance
{
int feet;
float inches;
public:
distance()
{
feet=0;
inches=0.0;
}
void getdist()
{
cout<<"\n Enter Feets ";
cin>>feet;
cout<<"\n Enter Inches ";
cin>>inches;
}
void showdist()
{
cout<<"\n Distance is "<<feet<<"-"<<inches;
}
distance operator+(distance);
};
distance distance::operator+(distance d)
{
distance temp;
temp.feet=feet+d.feet;
temp.inches=inches+d.inches;
return temp;
}
void main()
{
distance d1,d2,d3,d4,d5;
clrscr();
/////////////////
int a,b,c;
a=10;
b=20;
c=a+b;
cout<<"\n Sum is "<<c;
///////////////////////
d1.getdist();
d2.getdist();
d4.getdist();
d5.getdist();
d3=d1 + d2 + d4 + d5;
d3.showdist();
getch();
}
No comments:
Post a Comment