关于智能指针的问题,求助高手

johnny_ysx johnny_ysx 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
因为项目的需要,我自定义了一个简化的指针类方便在程序结束时候清理原始指针所指向的数据.但是程序在析构函数的时候报错(User breakpoint called from code at 0xxxxxxxxx),代码如下:
template<class T>
class IVPoint
{
private:
T* m_pIVPoint;

public:
IVPoint()
{
m_pIVPoint = NULL;
}
IVPoint(T* pIV){ m_pIVPoint = pIV; }
~IVPoint()
{
if (m_pIVPoint)
{
imaqDispose(m_pIVPoint);
}
}

T* GetInst()const{ return m_pIVPoint; }
T* operator->(){ return m_pIVPoint; }
T& operator*(){ return *m_pIVPoint; }

T* operator=(T* pIV)
{
if (m_pIVPoint && (m_pIVPoint != pIV))
{
imaqDispose(m_pIVPoint);
}
return (m_pIVPoint = pIV);
}

IVPoint<T>& operator=(const IVPoint<T>& IV )
{
if (IV.m_pIVPoint != m_pIVPoint)
{
imaqDispose(m_pIVPoint);
m_pIVPoint = IV.m_pIVPoint;

}

return *this;
}

int operator==(T* pIV)const{ return (m_pIVPoint == pIV); }
int operator!=(T* pIV)const{ return (m_pIVPoint != pIV); }

};
请高手指教到底错在哪里?
注: imaqDispose()是一个清理指针所指向数据的函数,在别处使用的时候没有问题. 谢谢各位啦!
...全文
评论 10
收藏 已收藏
分享
返回顶部
johnny_ysx
C++ 语言 65,214 成员 250,514 内容