Last active
August 29, 2015 14:20
-
-
Save thiagomg/210a4a3dd8a3eed539e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Construtor padrão | |
TestCopy() { | |
cout << "[CONSTR 1]" << endl; | |
this->val = 0; | |
} | |
//Construtor parametrizado | |
TestCopy(T val) { | |
cout << "[CONSTR 2:" << val << "]" << endl; | |
this->val = val; | |
} | |
//Copy constructor | |
TestCopy(const TestCopy &src) { | |
cout << "[COPY]" << endl; | |
this->val = src.val; | |
} | |
//Move constructor – Note que não há const e tem dois “&” na assinatura | |
TestCopy(TestCopy &&src) { | |
cout << "[MOVE]" << endl; | |
this->val = std::move(src.val); | |
} | |
//Operador = (atribuição) | |
TestCopy &operator =(const TestCopy &src) { | |
cout << "[OP=" << src.val << "]" << endl; | |
this->val = src.val; | |
} | |
//Final do programa + função auxiliar | |
void ts() { | |
cout << val << "===============" << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment