38 lines
460 B
Plaintext
38 lines
460 B
Plaintext
'======
|
|
class T
|
|
'======
|
|
|
|
float vv
|
|
|
|
method constructor(float a=0) {vv=a}
|
|
method destructor {}
|
|
method copy as T {new T ob : ob<=vv : return ob}
|
|
method mA() as float {return vv*2}
|
|
method mB() as float {return vv*3}
|
|
|
|
end class
|
|
|
|
|
|
'======
|
|
class S
|
|
'======
|
|
|
|
has T
|
|
|
|
method mB() as float {return vv*4} 'ovveride
|
|
|
|
end class
|
|
|
|
'====
|
|
'TEST
|
|
'====
|
|
|
|
new T objA(10.5)
|
|
|
|
let objB = cast S objA.copy
|
|
|
|
print objA.mb 'result 31.5
|
|
print objB.mb 'result 42
|
|
|
|
del objA : del objB
|