【发布时间】:2018-02-22 03:40:11
【问题描述】:
这是delete this 辩论的变体,与 intermediate 方法调用发生的情况有关。
基本上,如果方法 A 调用方法 B,并且方法 B 破坏了对象,那么从 B 返回时,方法 A 内部会发生什么特别的事情吗?像这样的:
struct test {
void A() {
B();
// what happens here besides being unable to dereference `this` anymore?
}
void B() {delete this;}
};
是否可以假设只要不再与前一个对象的内存位置交互,返回到过期对象的方法将正常进行?
【问题讨论】:
-
是的。 ]]]]]]]]]]]
标签: c++ c++11 callstack self-destruction