fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. class Box
  7. {
  8. public:
  9. int length, width, height;
  10. // Перегрузка постфиксной операции "++"
  11. Box operator++(int i){
  12. Box temp =*this;
  13. ++*this;
  14. return temp;
  15. }
  16. // Перегрузка постфиксной операции "--"
  17. Box operator--(int i){
  18. Box temp =*this;
  19. --*this;
  20. return temp;
  21. }
  22.  
  23. // Перегрузка префиксной операции "++"
  24. Box &operator++(){
  25. length++;
  26. width++;
  27. height++;
  28. return *this;
  29. }
  30.  
  31. // Перегрузка префиксной операции "--"
  32. Box &operator--(){
  33. length--;
  34. width--;
  35. height--;
  36. return *this;
  37. }
  38.  
  39. };
  40.  
  41.  
  42. int main(int argc, char * argv[])
  43. {
  44. Box b;
  45.  
  46. b++; ++b; b--; --b;
  47. Box c;
  48. c = b;
  49. c = ++b;
  50. c = b++;
  51. }
  52.  
Success #stdin #stdout 0.01s 5544KB
stdin
Standard input is empty
stdout
Standard output is empty