0

Greter then operator overloading

Hey guys i got an error in greter then operator overloading. plz help i cant understand what to do.

13th Oct 2018, 1:10 AM
vivek
vivek - avatar
3 Respostas
0
The first step is to show what you did and which error you got. Otherwise, we can only guess.
13th Oct 2018, 1:24 AM
Emerson Prado
Emerson Prado - avatar
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; }
13th Oct 2018, 1:26 AM
vivek
vivek - avatar
0
I solved it thanks
13th Oct 2018, 1:48 AM
vivek
vivek - avatar