fork(2) download
  1. #include <iostream>
  2.  
  3. struct A
  4. {
  5. int i;
  6. A(int ii) { i = ii; }
  7. A(const A& a) { i = a.i; i++; }
  8. A& operator=(const A& a) { i = a.i; i--; }
  9.  
  10. };
  11.  
  12. int main(void)
  13. {
  14. A a(4);
  15. std::cout << "a.i: " << a.i << '\n' ;
  16.  
  17. A b = a;
  18. std::cout << "a.i: " << a.i << '\n' ;
  19. std::cout << "b.i: " << b.i << '\n' ;
  20. return 0;
  21. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
a.i: 4
a.i: 4
b.i: 5