1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
// auto_ptr::release example
#include <iostream>
#include <memory>
int main () {
std::auto_ptr<int> auto_pointer (new int);
int * manual_pointer;
*auto_pointer=10;
manual_pointer = auto_pointer.release();
std::cout << "manual_pointer points to " << *manual_pointer << '\n';
// (auto_pointer is now null-pointer auto_ptr)
delete manual_pointer;
return 0;
}
|