Difference between revisions of "CPP/unique ptr"
From ProgrammingExamples
< CPP
(→unique_ptr.cpp) |
Daviddoria (Talk | contribs) |
||
| (2 intermediate revisions by 2 users not shown) | |||
| 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"> | ||
| Line 21: | Line 23: | ||
cmake_minimum_required(VERSION 2.6) | cmake_minimum_required(VERSION 2.6) | ||
| − | PROJECT( | + | PROJECT(unique_ptr) |
| − | ADD_EXECUTABLE( | + | ADD_EXECUTABLE(unique_ptr unique_ptr.cpp) |
</source> | </source> | ||
Latest revision as of 09: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)