How to declare an empty method?

It has been a few years since I have had to do this, but I need to declare a method in my base class, but produce no code for it. Then when this library is used by my second project I will derive a class from this base class and put the code into it there. How is this possible? I used to know how but do not remember how now.

The library is a static library designed for linking with both 32bit and 64bit Windows applications to handle a lot of the tedious stuff with Windows programming. The method in question handles specific command inputs. However, since each program that uses this library will have different uses for these commands, I want to leave it up to the user to code their own handling, but require it to be coded in the derived class.
virtual return_type member_function_name(parameters...) modifiers = 0;

The = 0 part is the key. This is called a Pure Virtual member function, and it makes the entire class Pure Virtual (aka Abstract, uninstantiable). Fun fact, though, you can still provide a definition for this function for deriving classes to call for some kind of default behavior - being pure virtual just means the deriving class must implement it if it doesn't want to be abstract.
Last edited on
That is it! I forgot the "= 0" at the end of my definition. Thanks for the help. I guess I should be using virtual methods more often so I can stay sharp!
Topic archived. No new replies allowed.