Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class Foo {
- public:
- Foo() : mA(0), mB(0) { std::cout << "Default constructor." << std::endl; }
- Foo(Foo &&other) : mA(std::move(other.mA)), mB(std::move(other.mB)) {
- std::cout << "Move constructor." << std::endl;
- }
- int mA;
- int mB;
- };
- class Bar {
- public:
- Bar(Foo foo) : mFoo(std::move(foo)) {}
- Foo mFoo;
- };
- int main() {
- Bar bar{Foo()};
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment