所以我是一个初学者,试图掌握操作员新手.我的析构函数有什么问题?
class arr{
public:
arr(){
pool=::operator new(100*sizeof(double));
}
~arr(){
::operator delete(pool);
}
void* pool;
};
int main()
{
arr a;
a.~arr(); //If I comment this out it's ok.
void* pool2=::operator new(100*sizeof(double)); //Works
::operator delete(pool2); //Fine.
system("pause");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
离开.~arr(); 在给我这个错误:
调试断言失败了!文件:dbgdel.cpp行:52
表达式:_BLOCK_TYPE_IS_VALID(pHead-> nBlockUse)
我不明白为什么pool2工作正常,但使用该类给我带来了问题.系统"暂停"后也会弹出错误,这是在.~arr()被调用之后???
谢谢!