Casting objects - Polymorphism

BlitzMax Forums/BlitzMax Beginners Area/Casting objects - Polymorphism

You are still putting health in the wrong place. (well, not wrong, but ill advised place)

IF Every derrived object is going to need access to a specific field name. ie Health, then it shuold be in the base class.

With health defined only in TAlien my code works fine
We know

My TAlien's baseclass was a class TUnit. And a TUnit has no health
Well. Are you sure? If you are sure that SOME units will not have health then fair enough put health in Talien

However, TAlien Small has TWO health fields
ATalienSmall.Health
ATailienSmall.Super.Health

And its the ATalienSmall.health set to 99

SO it should ONLY be in Talien

Edit. I should have read the whole thing before I posted. Oh well