Hello young
I have a class member (boost::shared_ptr):
class XYZ
{
private:
boost::shared_ptr<int> m_pBuff;
// other member
...
public:
void func(int n)
{
m_pBuff.reset(new int[n]); // or m_pBuff =
boost::shared_ptr<int>(new int[n])
...;
}
// other functions
...
}
The func(n) will be called many times inside / outside the class. Can I use
shared_ptr here like:
m_pBuff.reset(new int[n]);
or
m_pBuff = boost::shared_ptr<int>(new int[n]);
I tried both and get error said heap corruption.
--
View this message in context: http://boost.2283326.n4.nabble.com/how-to-use-boost-shared-ptr-tp4642120.html
Sent from the Boost - Users mailing list archive at Nabble.com.
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users