Difference between revisions of "CPP/unique ptr"
From ProgrammingExamples
< CPP
Daviddoria (Talk | contribs) m (moved CPP/auto ptr to CPP/unique ptr) |
Daviddoria (Talk | contribs) |
||
Line 1: | Line 1: | ||
+ | If you see 'auto_ptr' in code, it is simply the old version (deprecated) of unique_ptr shown in this example. | ||
+ | |||
==unique_ptr.cpp== | ==unique_ptr.cpp== | ||
<source lang="cpp"> | <source lang="cpp"> |
Latest revision as of 10:23, 6 April 2011
If you see 'auto_ptr' in code, it is simply the old version (deprecated) of unique_ptr shown in this example.
unique_ptr.cpp
#include <iostream> #include <memory> int main(int argc, char *argv[]) { std::unique_ptr<int> myInt(new int); *myInt = 5; std::cout << *myInt << std::endl; return 0; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.6) PROJECT(unique_ptr) ADD_EXECUTABLE(unique_ptr unique_ptr.cpp)