Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Foo
  6. {
  7. public:
  8. Foo(){cout << "Foo()" << endl;};
  9.  
  10. Foo(Foo&& f)
  11. {
  12. cout << "Foo(Foo&&)" << endl;
  13. this->x = 1;
  14. }
  15.  
  16. Foo(const Foo& f)
  17. {
  18. cout << "Foo(const Foo&)" << endl;
  19. this->x =2;
  20. }
  21.  
  22. int x;
  23.  
  24. static Foo get(){return Foo();}
  25. };
  26.  
  27.  
  28. int main(int argc, char* argv[])
  29. {
  30.  
  31. Foo foo2(Foo::get());
  32.  
  33. return 0;
  34. }
  35.  
  36. "Foo()".
  37.  
  38. "Foo()"
  39. "Foo(&&)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement