这是delete this
辩论的一种变体,与中间方法调用发生的情况有关。
基本上,如果方法 A 调用方法 B,并且方法 B 破坏了对象,那么从 B 返回时,方法 A 内部会发生什么特别的事情吗?像这样的东西:
struct test {
void A() {
B();
// what happens here besides being unable to dereference `this` anymore?
}
void B() {delete this;}
};
只要前一个对象的内存位置没有进一步交互,是否可以假设返回到过期对象的方法将正常进行?