智能指针

template <class T>
class PProtecter
{
public:
PProtecter(T * & pPointer): m_Pointer((T * *)&pPointer), m_bNeedDestroy(VOS_TRUE)
{
}

~PProtecter()
{
if ((VOS_TRUE == m_bNeedDestroy)
            && (VOS_NULL != m_Pointer)
            && (VOS_NULL != *m_Pointer))
{
VOS_DELETE(*m_Pointer);
*m_Pointer = VOS_NULL;
m_Pointer = VOS_NULL;
}
}


private:
T * * m_Pointer;
vos_bool m_bNeedDestroy;
};

你可能感兴趣的:(指针)