Explicitly declared destructors needed in derived classes?

Consider the following code snippet:

class A
{
virtual void function();
public:
  virtual ~A() {};
}

class B: public A
{
virtual void function() override final;
public:
  /*virtual*/ ~B() {}; // does this d-tor have to be declared at all?
}

I can easily find information about the base class destructor, for example. http://en.cppreference.com/w/cpp/language/destructor

"Deleting an object using a pointer to the base causes undefined behavior if the destructor in the base class is virtual. In general, the destructor of the base class must be open and virtual, or protected and not virtual."

, , /? , . vtable / ? :

class A
{
virtual void function();
public:
  virtual ~A() {};
}

class B: public A
{
virtual void function() override;
public:
  /*virtual*/ ~B() {}; // does this d-tor have to be declared at all?
}

class C: public B
{
virtual void function() override final;
public:
  /*virtual*/ ~C() {};  // does this d-tor have to be declared at all?
}
+3
3

. ++

, ( , )

, ,

.

vtable. , vtable .

, ,

class B: public A
{
virtual void function() override final;
public:
  virtual ~B() = default;
}
+5

, ; , , virtual, virtual virtual. , .

+3

, , do-nothing , .

, C B - VendorBAwesomeness.dll, B, , Microsoft A mswonderful.dll.

, virtual C, B, , B , .

, , , .

0

All Articles