Take the 2-minute tour ×  How would you go around creating a
reusable weapon class? I can't really wrap my head around
creating a class, which will work for both melee and ranged
weapons.  Example given, that you have a knife, an RPG, and you
have an ordinary pistol. How would you go around creating a
class all three can inherit from?  share|improve this question
Think about what they have in common and what is dfferent for
each of them. That's the first step. –  Maik Semder Sep 14 '11
at 14:07  3 Answers 3  up vote 5 down vote accepted  The same
way you design any inheritance structure: You think about what
all weapons, without exception, have in common. Obviously,
damage comes to mind. Attack rate. Remember that you don't have
to (and should not!) cramp everything into the base class. You
put into a class what you need it (and all child classes) to do,
no more and no less.  Next step, you could make 2 classes,
MeleeWeapon and RangedWeapon, which both inherit from Weapon.
Maybe that split is necessary becaus