override a base property or make a new one for inheritor?

Another inheritance question on best practice.

if i have weapon property

get projectile

set projectile


ballistic weapon

but ballistic weapon has a ballistic projectile (which inherits from projectile)

do/should I make a new property or override the old one or what.

Basically ballistic weapon class has a projectile (and inherits the get/set property for a projectile from its base class weapon)

however it more specifically has a ballistic projectile which has things like projectile speed that a non ballistic laser weapon doesn’t.

So should I override the original getter/setter and have the original getter/setter be virtual or do I make a new getter/setter

I’m concerned if i make a new one that i’d end up with 2 nearly identical properties for one weapon.

it’d have the get projectile & get ballistic projectile when really the ballistic is probably all it needs (since it inherits it can do the generic stuff still as well as specific)

But I was wanting to make sure that is how people who have dealt with inheritance more would do it.

I say use one getter, since you can access all the ‘weapon’ properties just as well. It seems redundant to have two separate getters.

Except I’d maybe implement it all through interfaces (if you’re composite weapons then definitely use interfaces) but yeah, polymorphism was invented to solve exactly that kind of problem. :slight_smile: