fb:porticula NoPaste
Fehlverhalten bei Vererbung und "extends object"
Uploader: | MilkFreeze |
Datum/Zeit: | 25.12.2011 16:44:44 |
type test_one extends object
x as integer
y as integer
end type
type expand_one extends test_one
z as integer
end type
dim t1_xo as expand_one
t1_xo.x = 1
t1_xo.y = 2
t1_xo.z = 3
? t1_xo.x
? t1_xo.y
? t1_xo.z
dim t1 as test_one ptr
t1 = @t1_xo
'works!
? t1->x
? t1->y
'also works!
't1 = 0
'does not work
'but hey, this works:
t1 = cast(any ptr,0)
'but look:
type test_two
x as integer
y as integer
end type
type expand_two extends test_two
z as integer
end type
dim t2_et as expand_two
t2_et.x = 4
t2_et.y = 5
t2_et.z = 6
? t2_et.x
? t2_et.y
? t2_et.z
'works!
dim t2 as test_two ptr
t2 = @t2_et
? t2->x
? t2->y
'works!!
t2 = 0
'works!