
please wait
A prospective destructor can be declared virtual and with a pure-specifier. If the destructor of a class is virtual and any objects of that class or any derived class are created in the program, the destructor shall be defined. http://eel.is/c++draft/class.dtor#12 |
JLBorges wrote: |
---|
It is actually required if the standard wants to allow the destructor of a class to be pure virtual. |
2. Why might you declare a pure virtual function and also write a definition (body)? Give as many reasons or situations as you can. There are three main reasons you might do this. #1 is commonplace, #2 is pretty rare, and #3 is a workaround used occasionally ... Most programmers should only ever use #1. #1. Pure Virtual Destructor ... If the class should be abstract (you want to prevent instantiating it) but it doesn't happen to have any other pure virtual functions, a common technique to make the destructor pure virtual #2. Force Conscious Acceptance of Default Behaviour ... #3. Workaround Poor Compiler Diagnostics ... http://www.gotw.ca/gotw/031.htm |
|
|
With the quirk one can provide an abstract class, yet include default implementations for all of its member functions. |