boost库的shared_ptr怎么当类的成员变量用
在一个类中,不用这个智能指针时,可以直接定义一个变量,比如int* m_pInt,然后在构造函数或初始化函数之类的地方写m_pInt = new int[111];
现在想要把m_pInt换shared_ptr<int> m_pInt的,要怎么做呢?
[解决办法]
shared_ptr<int> m_pInt2 = shared_ptr<int>(m_pInt);
[解决办法]
reset(new int(300));
ok?