#include<iostream.h>
#include<conio.h>
class Distance{
private:
int feet;
int inches;
public:
Distance(){
feet=0;
inches=0;
}
Distance(int f, int i)
{
feet=f;
inches=i;
}
void display()
{
cout<<"f:"<<feet <<"i:"<<inches;
}
Distance operator--()
{
feet=--feet;
inches=--inches;
return Distance(feet,inches);
}
};
void main(void)
{
Distance D1(11,10);
//Distance D(-10,-12);
--D1;
D1.display();
//D.display();
getch();
}
#include<conio.h>
class Distance{
private:
int feet;
int inches;
public:
Distance(){
feet=0;
inches=0;
}
Distance(int f, int i)
{
feet=f;
inches=i;
}
void display()
{
cout<<"f:"<<feet <<"i:"<<inches;
}
Distance operator--()
{
feet=--feet;
inches=--inches;
return Distance(feet,inches);
}
};
void main(void)
{
Distance D1(11,10);
//Distance D(-10,-12);
--D1;
D1.display();
//D.display();
getch();
}
No comments:
Post a Comment