fork(1) download
  1. #include <iostream>
  2.  
  3. struct Foo
  4. {
  5. Foo() : a(10), b(20) {}
  6. ~Foo() { std::cout << "In Foo::~Foo()\n"; }
  7. int a;
  8. int b;
  9. };
  10.  
  11. Foo getFoo()
  12. {
  13. return Foo();
  14. }
  15.  
  16. void testFoo1()
  17. {
  18. int const& r = getFoo().a;
  19. std::cout << "In testFoo1()\n";
  20. (void)r; // Shut up the compiler
  21. }
  22.  
  23. int main()
  24. {
  25. testFoo1();
  26. }
  27.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
In Foo::~Foo()
In testFoo1()