Extending Types * 2

BlitzMax Forums/BlitzMax Beginners Area/Extending Types * 2

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.

Sorry to hijack this thread but Im wondering using the above code - how do you reference the Extended type (tstudent) to be used with an function outside the type.

Type TStudent
	Field age%

	Method GetAge%()
		Return age
	End Method
End Type

Type TStudentMusician Extends TStudent
End Type

Type ITStudent Extends TStudent
End Type

'
'How can you reference the age field using a function ?
'
Local student1:TStudentMusician = New  TStudentMusician
Local student2:ITStudent = New  ITStudent

student1.age = 23
student1.age = 28

DebugLog( ShowAge(student1))
DebugLog( ShowAge(student2))

Function ShowAge:Int( studentdata:Object )  ' <<< how to pass 

    Return Studentdata.age

End Function


NO sooner I post then I find the answer


    Return Tstudent(Studentdata).age