In C ++, you can define a pure virtual method. For instance:
.
Now that the dllexport / dllimport specifier is added to the T class, you will choose the doSomething method.
The point of determining the body of a pure virtual method was to make sure that the user overrides this method, while maintaining the default implementation.
My own use of this template is to avoid crashing when for some reason the virtual method is called before it exists or when it no longer exists (i.e. in the constructor or destructor of the base abstract class). In debug mode, it will launch the debugger ( ::DebugBreak() function of the Win32 API), and in release mode it will do nothing.
But this template can also be used to solve your problem if you really need to export your pure virtual functions.
source share