The reasons may vary from breaking principle/guidelines of OO to considering protected as part of public API.
Then, what should we do if some derived classes have same members? Should we declare them in base class and inherit them? Or should we declare them in derived classes multiple times?
For example, class Warrior and class Wizard both have members such as hp, atk, def, and are derived from base class Player. class Warrior has its own member fury, while class Wizard has its own member mana.
- declare hp, atk, def in class Player as protected and declare fury as private in class Warrior, mana in Wizard?
- declare hp, atk, def, fury(Warrior only), mana(Wizard only) in class Warrior and class Wizard as private?
Which one is the better practice, and why?
PS: I was told this question is primary-opinion based, but I would still like to know how people decide when to implement one of which, thanks.