fork(2) download
  1. #include <iostream>
  2. struct Foo {
  3. Foo() = default;
  4. Foo(const Foo &) {}
  5. Foo(Foo &&) = default;
  6. };
  7.  
  8. struct Bar {
  9. Bar() = default;
  10. Bar(const Bar &) = default;
  11. Bar(Bar &&) {}
  12. };
  13.  
  14. Foo GetFoo() {
  15. Foo foo;
  16. std::cout << "GetFoo:" << &foo << std::endl;
  17. return foo;
  18. }
  19.  
  20. Bar GetBar() {
  21. Bar bar;
  22. std::cout << "GetBar:" << &bar << std::endl;
  23. return bar;
  24. }
  25.  
  26. int main() {
  27. Foo foo = GetFoo();
  28. std::cout << "foo:" << &foo << std::endl;
  29. Bar bar = GetBar();
  30. std::cout << "bar:" << &bar << std::endl;
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
GetFoo:0x7ffef04f5b6e
foo:0x7ffef04f5b6e
GetBar:0x7ffef04f5b6f
bar:0x7ffef04f5b6f