fork(7) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Foo
  5. {
  6. public:
  7. Foo()
  8. {
  9. cout << "Constructed!" << endl;
  10. }
  11.  
  12. Foo(const Foo&)
  13. {
  14. cout << "Copied!" << endl;
  15. }
  16.  
  17. Foo(Foo&&)
  18. {
  19. cout << "Movied!" << endl;
  20. }
  21.  
  22. int data = 3;
  23. };
  24.  
  25. Foo returns_a_foo()
  26. {
  27. Foo foo;
  28. foo.data = 5;
  29. return foo;
  30. }
  31.  
  32. int main() {
  33. // your code goes here
  34. Foo foo = returns_a_foo();
  35. cout << "Foo's data is " << foo.data << endl;
  36. return 0;
  37. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
Constructed!
Foo's data is 5