fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct circle {
  5. double Area, x,y;
  6. circle& operator++ () {
  7. Area = Area * 2.0;
  8. cout << "prefix"<<endl;
  9. return *this;
  10. }
  11. circle operator++ (int) {
  12. circle c(*this);
  13. Area = Area * 2.0;
  14. cout << "postfix"<<endl;
  15. return c;
  16. }
  17. void output() { cout <<Area<<" "<<x<<" "<<y<<endl; }
  18. };
  19.  
  20.  
  21. /////////////////////////////
  22.  
  23. int main()
  24. {
  25. class circle c1{4, 1, -1}, c2{12, 4, 6};
  26. cout<<"Original: ";
  27. c1.output();
  28. cout<<"Postfix before: ";
  29. (c1++).output();
  30. cout<<"Postfix after: ";
  31. c1.output();
  32. cout<<"Prefix: ";
  33. (++c1).output();
  34.  
  35. system("pause");
  36. return 0;
  37. }
  38.  
  39.  
Success #stdin #stdout #stderr 0s 3460KB
stdin
Standard input is empty
stdout
Original: 4 1 -1
Postfix before: postfix
4 1 -1
Postfix after: 8 1 -1
Prefix: prefix
16 1 -1
stderr
sh: 1: pause: not found