I came across the following code in a header file:
class Engine
{
public:
void SetState( int var, bool val );
{ SetStateBool( int var, bool val );
Private virtual method is used for limiting the number of derived classes that can override the given function. The derived classes that has to override the private virtual method will have to be a friend of the base class.
A brief explanation can be found of DevX.com.
EDIT A private virtual method is effectively used in Template Method Pattern. The derived classes can override the private virtual method but the derived classes cannot call it's base class private virtual method (in your example, SetStateBool
and SetStateInt
). Only the base class can effectively call its private virtual method (Only if derived classes need to invoke the base implementation of a virtual function, make the virtual function protected).
An interesting article can be found about Virtuality.