Skip to content

Instantly share code, notes, and snippets.

@skomik
Created June 12, 2014 09:53
Show Gist options
  • Save skomik/d9b9f3a677057b6c73b7 to your computer and use it in GitHub Desktop.
Save skomik/d9b9f3a677057b6c73b7 to your computer and use it in GitHub Desktop.
#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