-
-
Save jitpaul/decf9499607c692ed4eafd49c2a1920e to your computer and use it in GitHub Desktop.
Smart Pointers
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
#include <memory> | |
using namespace std; | |
int main(){ | |
unique_ptr<int> a(new int(4)); // correct | |
unique_ptr<int> b = a; //compiler error | |
unique_ptr<int> b = move(a); //correct. 'a' is invalidated. | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment