pure virtual question this time

Would it be correct to always use pure virtual instead of just virtual in a base class if the virtual function definition of the base class does nothing. assuming you are going define your own functions for it later in derived classes
Last edited on
In the world of programming, "always" rules are pretty few and far between. Generally if you have to ask whether you should "always" do something, the answer is no, because there's likely to be exceptions to any rule.

In this case the answer is definitely "no". An empty virtual function in a base class can have a purpose in some cases. Pure virtual functions should be used when you want to require that a derived class implement such a function.

If such functionality is optional, you might want to use an empty virtual function instead.
thanks for the insite. i will certainly give more thought to the actual requirements. especially if the derived class must implement a function.
Topic archived. No new replies allowed.