Guest User

Untitled

a guest
Aug 20th, 2024
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. class Foo {
  4. public:
  5. Foo() : mA(0), mB(0) { std::cout << "Default constructor." << std::endl; }
  6.  
  7. Foo(Foo &&other) : mA(std::move(other.mA)), mB(std::move(other.mB)) {
  8. std::cout << "Move constructor." << std::endl;
  9. }
  10.  
  11. int mA;
  12. int mB;
  13. };
  14.  
  15. class Bar {
  16. public:
  17. Bar(Foo foo) : mFoo(std::move(foo)) {}
  18. Foo mFoo;
  19. };
  20.  
  21. int main() {
  22. Bar bar{Foo()};
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment