隐式定义的析构函数做什么

What does a implicitly defined destructor do

隐式定义的析构函数有什么作用?它只是一个由编译器定义的空函数吗?

struct Foo
{
  int i;
};

struct Bar
{
  int i;
  ~Bar()
  { 
    // empty...
  }
};

Foo的销毁和Bar一样吗?或者隐式析构函数是否在编译器生成的主体内部执行某些操作?

What does the implicitly defined destructor do?

它将与具有空主体的显式定义的析构函数相同。实际上,它会销毁所有子对象并且什么都不做。

Is it just an empty function that is defined by the compiler?

实际上,甚至可能不需要空函数。但是当从抽象机器的角度思考时,认为存在可能是有用的。

Or does the implicit destructor do something inside of the compiler generated body?

取决于 class。在Foo的情况下,析构函数不需要做任何事情。