这是delete this辩论的变体,与中间方法调用发生了什么。 基本上,如果方法A调用方法B,并且方法B销毁该对象,那么从B返回时方法A中会发生什么特别的事情?事情是这样的: struct test {
void A() {
B();
// what happens here besides being unable to dereference `this` an
删除可能重复: Should “delete this” be called from within a member method? 是正确调用从的OnOK事件处理函数删除,如下面的代码。 void CTestDlg::OnOK()
{
CDialog::OnOK();
this->DestroyWindow();
delete this;
}