LuckyLucks
asked on
Base classes and virtual functions
Hi
I have a Base class that has quite a few functions which are virtual because I also want the Derived class to define them.
However, I am wrestling with some functions that are more of a *helper type* variety in the Base class. Should I make them virtual or not? Note: I am not planning to make them pure virtual (derived class may choose not to define them). If I make them virtual, the derived classes aren't even going to define them since they are suited to Base class.
However if i don't define them as virtual and just leave them in the Base class (int a; instead of virtual int a;), then i am worried that the derived class will inherit them
Is there a way for the derived class to *not inherit* these helper functions?
What is the best design in cases like this?
I have a Base class that has quite a few functions which are virtual because I also want the Derived class to define them.
However, I am wrestling with some functions that are more of a *helper type* variety in the Base class. Should I make them virtual or not? Note: I am not planning to make them pure virtual (derived class may choose not to define them). If I make them virtual, the derived classes aren't even going to define them since they are suited to Base class.
However if i don't define them as virtual and just leave them in the Base class (int a; instead of virtual int a;), then i am worried that the derived class will inherit them
Is there a way for the derived class to *not inherit* these helper functions?
What is the best design in cases like this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.