fork(1) download
  1. #include <iostream>
  2.  
  3. struct Bar {
  4. Bar() {
  5. std::cout << "bar" << this<< std::endl;
  6. }
  7.  
  8. ~Bar() {
  9. std::cout << "~bar" << this<<std::endl;
  10. }
  11. };
  12.  
  13. struct Foo {
  14. Foo(Bar && = Bar()) {
  15. std::cout << "foo:" << this << std::endl;
  16. }
  17.  
  18. ~Foo() {
  19. std::cout << "~foo:" << this << std::endl;
  20. }
  21. };
  22.  
  23. void test(Foo = Foo()) {
  24. std::cout << 5566 << std::endl;
  25. }
  26.  
  27. int main() {
  28. std::cout << 1 << std::endl;
  29. {
  30. Foo foo;
  31. std::cout << 5566 << std::endl;
  32. }
  33. std::cout << 2 << std::endl;
  34. test();
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 3416KB
stdin
Standard input is empty
stdout
1
bar0xbfe44f2f
foo:0xbfe44f2e
~bar0xbfe44f2f
5566
~foo:0xbfe44f2e
2
bar0xbfe44f2f
foo:0xbfe44f2e
5566
~foo:0xbfe44f2e
~bar0xbfe44f2f