Advertisement
raju02

Relational operator overloading .cpp

Jan 5th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. class number{
  4. int x , y;
  5. public:
  6. number(){x = 0, y = 0;}
  7. void input(){ cin >> x >> y;}
  8. void set (int a , int b)
  9. {
  10. x = a , y = b;
  11. }
  12. bool operator > (number ob)
  13. {
  14. return x + y > ob.x + ob.y;
  15. }
  16. bool operator < (number ob)
  17. {
  18. return x +y < ob.x + ob.y;
  19. }
  20. bool operator == (number ob)
  21. {
  22. return (x +y) == (ob.x + ob.y);
  23. }
  24.  
  25. };
  26. int main()
  27. {
  28. number n1 ,n2 , n3;
  29. n1.input();
  30. n2.input();
  31. if(n1 > n2)
  32. printf("N1 is greater then N2\n");
  33. else if(n1 < n2)
  34. printf("N2 is greater then N1\n");
  35. else if(n1 == n2)
  36. printf("Twice are same\n");
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement