Does destroying and recreating an object make all pointers to this object invalid?

后端 未结 6 1597
我寻月下人不归
我寻月下人不归 2021-01-11 23:46

This is a follow-up to this question. Suppose I have this code:

class Class {
    public virtual method()
    {
        this->~Class();
        new( this          


        
6条回答
  •  悲&欢浪女
    2021-01-11 23:57

    You may want to reconsider explicitly calling the destructor. If there's code you want executed that happens to be in the destructor, move that code to a new method and call that method from the destructor to preserve the current functionality. The destructor is really meant to be used for objects going out of scope.

提交回复
热议问题