Call extended type method from base type instance

BlitzMax Forums/BlitzMax Programming/Call extended type method from base type instance

I may be misunderstanding you, but virtual methods take care of this automatically.

It doesn't matter whether fruit1 or fruit2 are defined as Fruit objects or the actual types from which they are instantated.

Type Fruit
	Method whatAmI() Abstract
End Type

Type Apple Extends Fruit
	Method whatAmI()
		Print "I am an apple"
	End Method
End Type

Type Orange Extends Fruit
	Method whatAmI()
		Print "I am an orange"
	End Method
End Type

Local fruit1:Fruit=New Apple
Local fruit2:Fruit=New Orange

fruit1.whatAmI()
fruit2.whatAmI()