0
Greter then operator overloading
Hey guys i got an error in greter then operator overloading. plz help i cant understand what to do.
3 odpowiedzi
0
The first step is to show what you did and which error you got. Otherwise, we can only guess.
0
#include <iostream>
using namespace std;
class distance
{
int feet;
int inch;
public:
distance()
{
feet=0;
inch=0;
}
distance(int f , int i )
{
feet=f;
inch=i;
}
void display()
{
cout<<"F:"<<feet <<"I:"<<inch;
}
distance operator-()
{
feet=-feet;
inch=-inch;
return distance(int f, int i);
}
bool operator >(const distance &d);
{
if (feet>d.feet)
{
return true;
}
if(feet == d.feet && inch>d.inch)
{
return true;
}
else
return false;
}
};
int main() {
distance D1(10,15), D2(5,8)
if(D1 > D2{
cout<<"D1 is greter"<<D1;
}
else
{
cout<<"D2 is greter"<<D2;
}
return 0;
}
0
I solved it thanks