Last active
August 19, 2020 09:00
-
-
Save junaidrahim/f4d59bc0ba34571fff1a0530397ec6ac to your computer and use it in GitHub Desktop.
Unique Pointer Example 2
This file contains hidden or 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 <iostream> | |
#include <memory> | |
using namespace std; | |
void DoSomething(){ | |
unique_ptr<int[]> p = make_unique<int[]>(50); | |
// do some processing with the array | |
} // p is automatically freed when it goes out of scope. | |
int main(){ | |
DoSomething(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment