Search code examples
c++virtual-destructor

virtual destructor signature


For virtual mechanism we need to have method name same in base and derived classes. However in case of virtual destructors, names can be different.

Can anybody explain how virtual mechanism(V-Ptr, V-Table) supports/works with differently named destructors.


Solution

  • It's up to the implementation, just as long as it ensures that it can call the correct destructor. The means of doing so could be part of the general virtual mechanism, or it could be a special mechanism just for destructors.

    One would expect that function names don't appear in vtables anyway: the compiler just assigns an offset into the table for each virtual function in each class. So the issue of whether destructors have names, and if so what they are, isn't relevant.