我有以下课程:
class estimate
{
public:
estimate();
~estimate();
double *tHanning;
}
estimate::estimate()
{
tHanning = NULL;
tHanning = new double [1000];
for (int m=0; m<1000; m++)
{
tHanning[m]=(0.5-0.5*cos(2.0*PI*(m+1)/(1001)));
}
}
estimate::~estimate()
{
delete [] tHanning;
tHanning = NULL;
}
当我将“new”分配给变量时,我不确定为什么 C++ Memory Validator 在构造函数中显示资源泄漏。
有人能帮帮我吗?
编辑:我如何起诉上述课程:
class HBMain
{
public:
HBMain();
~HBMain();
bool Init();
estimate *objEstimate;
}
HBMain :: HBMain()
{
objEstimate = NULL;
}
HBMain :: ~HBMain()
{
delete objEstimate;
objEstimate = NULL;
}
bool HBMain :: Init()
{
....
objEstimate = new estimate();
....
}