fork download
  1. #include <iostream>
  2. struct MyStruct {
  3. int a;
  4. };
  5.  
  6. int& operator++(MyStruct& val) {
  7. return val.a+=1;
  8. } // Prefix form.
  9.  
  10. int operator++(MyStruct& val, int) {
  11. MyStruct temp{val.a++};
  12. return temp.a;
  13. } // Postfix form
  14. int main() {
  15. MyStruct v;
  16. v.a = 10;
  17. std::cout << v++ << ++v;
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5476KB
stdin
Standard input is empty
stdout
1012