在成员函数中调用析构函数

时间:2018-03-17 14:25:05

标签: c++ destructor new-operator

假设我有一个这样的类:

#include <new>
struct thing {
  thing() = default;
  void foo()
  {
    this->~thing();
    new (this) thing();
  }
};

是这样调用析构函数然后使用放置新定义的行为重构对象吗?

0 个答案:

没有答案
相关问题