#include<iostream>
#include<cstring>
#include<memory>
using namespace std;
class Investment{
};
Investment* createInvestment(){
}
void f(){
//Investment* pInv = createInvestment();
//delete pInv;
//智能指针,其析构函数自动对其所指对象调用delete
//要注意别让多个auto_ptr指向同一对象
std::auto_ptr<Investment> pInv(createInvestment());
//auto_ptr的性质,若通过copy构造函数或copy assignment操作符复制它们,它们会变成null,而复制所得的指针将取得资源的唯一所有权
std::auto_ptr<Investment> pInv2(pInv);
//引用计数型智慧指针
std::tr1::shared_ptr<Investment> pInv2(createInvestment());
}
int main(){
}
07-28
07-28