change extended type

BlitzMax Forums/BlitzMax Programming/change extended type

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.

Type TDOB 'date of birth
  Field day:Int, month:Int, year:Int
  Method toAge:TAge()
    Local age:TAge = New TAge
    'code here to convert dob into an age in years
    Return age
  End Method
End Type

Type TAge 'age in years
  Field years:Float 'the years will need to be stored as decimal to get an accurate dob
  Method toDOB:TDOB()
    Local dob:TDOB = New TDOB
    'code here to convert years into dob
    Return dob
  End Method
End Type

Local age:TAge = New TAge
age.years = 20
Local dob:TDOB = age.toDOB()


Not tested but should show the point, even if it's a trivial example. (Notice a New is not required for the last line).