在C++中,当delete调用析构函数时,析构函数体是否在释放内存之前触发?

In C++, when delete calls the destructor, does the body of the destructor trigger before memory is freed?

例如,我正在尝试使用此递归析构函数删除二叉树:

~BinTreeNode() {
    delete left;
    delete right;
    // delete this; <- i'm assuming this is implicit, so i don't need to include it
}

如果我delete root;其中root是根节点,是否会成功释放整个树的内存?

是的。析构函数的主体必须在内存被释放之前发生。你不需要删除它,因为你已经是...所以如果你这样做,那么坏事就会发生。