#include <iostream.h>
#include <conio.h>
class distance
{
int feet;
float inches;
public:
distance()
{ feet=0;inches=0.0;}
distance(int ft,float in)
{ feet=ft; inches=in;}
void getdist()
{
cout<<"\nEnter feet : ";
cin>>feet;
cout<<"\nEnter Inches : ";
cin>>inches;
}
void showdist()
{
cout<<feet<<"\'-"<<inches<<'\"';
}
distance operator + (distance);
};
distance distance :: operator + (distance d2)
{
int f = feet + d2.feet;
float i = inches + d2.inches;
if(i >= 12.0)
{
i = i - 12.0;
f++;
}
return distance(f,i);
}
#include <conio.h>
class distance
{
int feet;
float inches;
public:
distance()
{ feet=0;inches=0.0;}
distance(int ft,float in)
{ feet=ft; inches=in;}
void getdist()
{
cout<<"\nEnter feet : ";
cin>>feet;
cout<<"\nEnter Inches : ";
cin>>inches;
}
void showdist()
{
cout<<feet<<"\'-"<<inches<<'\"';
}
distance operator + (distance);
};
distance distance :: operator + (distance d2)
{
int f = feet + d2.feet;
float i = inches + d2.inches;
if(i >= 12.0)
{
i = i - 12.0;
f++;
}
return distance(f,i);
}
0 comments:
Post a Comment