Jump to content

Polymorphic copy: Difference between revisions

Line 876:
::method name
return "S"
</lang>
 
=={{header|OxygenBasic}}==
<lang oxygenbasic>
'======
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
</lang>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.