fork download
  1. #include<iostream>
  2. #include<cstring>
  3. using namespace std;
  4. class base{
  5. int x,y;
  6. public:
  7. base(int x=0,int y=0){
  8. this->x = x;
  9. this->y = y;
  10. }
  11. void get_xy(int &a,int &b){
  12. a = x;
  13. b = y;
  14. }
  15. friend base operator--(base &ob,int n);
  16. };
  17. base operator--(base &ob,int n){
  18. ob.x--;
  19. ob.y--;
  20. return ob;
  21. }
  22.  
  23. int main ()
  24. {
  25. int c,d;
  26. base obj(1000,2000);
  27. obj--;
  28. obj.get_xy(c,d);
  29. cout<<c<<" "<<d;
  30. return 0;
  31. }
  32.  
  33.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
999 1999