fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct BreakConst
  5. {
  6. int v;
  7. int *p;
  8. BreakConst() { v = 0; p = &v; }
  9. void break_stuff() const { ++*p; }
  10. };
  11. void f(const BreakConst& bc) {
  12. bc.break_stuff();
  13. }
  14.  
  15. int main()
  16. {
  17. BreakConst bc;
  18. cout << bc.v << endl; // 0
  19. f(bc); // O:)
  20. cout << bc.v << endl; // 1
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0.02s 2680KB
stdin
Standard input is empty
stdout
0
1