Advertisement
Guest User

Untitled

a guest
Sep 15th, 2022
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. class Foo {
  2. public:
  3.     int a, b;
  4.    
  5.     Foo(int a, int b) : a(a), b(b) {
  6.        
  7.     }
  8. };
  9.  
  10. int main()
  11. {
  12.     Foo foo(14, 88);
  13.  
  14.     auto& foo_ref = foo; //lvalue reference
  15.     auto&& foo_ref2 = foo;
  16.    
  17.     auto foo2 = foo_ref; //copy
  18.    
  19.     auto foo3 = foo_ref2; //move
  20.     //foo, foo_ref and foo_ref2 are invalid now
  21.  
  22.     return 0;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement