解釋auto_ptr
#include <iostream> #include <memory> using namespace std;
int main() { ? ? ? ? auto_ptr<int> pi ( new int(1024) ); ? ? ? ? cout << *pi << endl; ? ? ? ? return 0; } 回答:
auto_ptr是C++標準庫提供的類模板,它可以幫助程序員自動管理用new表達式動態分配的單個對象。當auto_ptr對象的生命期結束時,動態分配的對象被自動釋放。
|
posted on 2006-11-10 14:06
喬棟 閱讀(289)
評論(0) 編輯 收藏 引用 所屬分類:
C++的健身房