Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <iostream>
class MemberClass{
public:
MemberClass() { std::cout << "MemberClass: default constructor\n"; }
MemberClass(const MemberClass&) { std::cout << "MemberClass: copy constructor\n"; }
MemberClass(MemberClass&&) { std::cout << "MemberClass: move constructor\n"; }
MemberClass& operator=(const MemberClass&) { std::cout << "MemberClass: copy assignment\n"; return *this; }
MemberClass& operator=(MemberClass&&) { std::cout << "MemberClass: move assignment\n"; return *this; }
};
class Base {
public:
virtual ~Base() {}
private:
MemberClass member;
};
class Derived : public Base {
private:
MemberClass member;
};
int main()
{
Derived d1;
Derived d2 = std::move(d1);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment