fork(2) download
  1. #include <iostream>
  2.  
  3. struct A {
  4. A(int i) : i(i) {}
  5. A & operator = ( const A & a )
  6. {
  7. std::cout << "op=(" << i << "," << a.i << ") ";
  8. i = a.i;
  9. return *this;
  10. }
  11. int i = 0;
  12. };
  13.  
  14. A & bar( int n ) {
  15. std::cout << "bar(" << n << ") ";
  16. return *new A(n);
  17. }
  18.  
  19. int main() {
  20. bar( 1 ) = bar( 2 ) = bar( 3 );
  21. std::cout << std::endl;
  22. }
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
bar(3) bar(2) op=(2,3) bar(1) op=(1,3)