Types and polymorphism

BlitzMax Forums/BlitzMax Beginners Area/Types and polymorphism

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Well, without seeing your code, I don't know if this is the problem or not, but I'm guessing that you are redefining somevalue in THuman.

Try copying and pasting this and you'll see it works...
Strict

Type Entity
Field SomeValue:Int

Method New() 
SomeValue = 55
EndMethod

EndType

Type Human Extends Entity

EndType

Local Hum:Human = New Human
Local ent:Entity
ent = Hum

Print "Ent.Somevalue = " + ent.somevalue
Print "Hum.SomeValue = " + hum.somevalue


However, if you change type human to the following, it won't work.
Type Human Extends Entity
field SomeValue:int
EndType


In this case, you've redefined SomeValue in type Human, and this redefined value is NOT set in the base class New() method.