Skip to content

Instantly share code, notes, and snippets.

@pasberth
Created June 4, 2014 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pasberth/3ad3c0be035a231f8f77 to your computer and use it in GitHub Desktop.
Save pasberth/3ad3c0be035a231f8f77 to your computer and use it in GitHub Desktop.
#include <iostream>
struct A {
int x;
A(int x) : x(x) {}
void assign_self(A& a) {
*this = a;
}
};
int main() {
A a1(1);
A a2(2);
a1.assign_self(a2);
std::cout << a1.x << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment