My Class Hierarchy is thus: BaseClass (is an abstract class) then it has three subclasses that inherit from it: ArcaneWarrior, Guardian, Magi.
I want to have two non-changing values for DefaultHealth and DefaultMana that are specific to each subclass as they will all have different values for both variables.
I guess I’m just looking for the best/most efficient way to do this.
Should I just have two virtual functions in the base class to return DefaultHealth and DefaultMana, and in the subclasses hard code in the values I want?
I appreciate any insight
My vote goes to
constvalues in the base class and aprotectedconstructor:This is superior to the
virtualfunction approach in 2 ways:const-ness (those values can’t be changed, ever)Virtual functions don’t give you
const-ness, see this example: