在c++程序中,內存管理中經常隱藏著很深的bug。
         雖然我們一般可以采用vector,string,map等容器自動管理內存,
但涉及多態(tài),繼承的時候也不可避免的要手動管理,c++標準庫中提供的能一定程度上幫助我們。

用法:
1.需要包含頭文件

2.Constructor:explicit (X* p = 0) throw();
將指針p交給對象托管

3.Copy constructor:
(const &) throw();
template (const & a) throw();
指針的托管權會發(fā)生轉移

4.Destructor: ~();
釋放指針p指向的空間

5.提供了兩個成員函數
X* get() const throw();//返回保存的指針,對象中仍保留指針
X* release() const throw();//返回保存的指針,對象中不保留指針