Inheritance/Multiple: Difference between revisions

implement a demonstrative program in nim lang in the light of lack of multiple inheritance
m (→‎{{header|Phix}}: added to Phix/Class)
(implement a demonstrative program in nim lang in the light of lack of multiple inheritance)
Line 1,048:
click...
ring...</pre>
 
=={{header|Nim}}==
nim does not support multiple inheritance (version<=1.4.6). It is just a demonstration of the procedure reloading nature of nim code.
<lang nim>type
Camera = ref object of RootObj
MobilePhone = ref object of RootObj
CameraPhone = object
camera: Camera
phone: MobilePhone
proc `is`(cp: CameraPhone, t: typedesc): bool =
for field in cp.fields():
if field of t:
return true
var cp: CameraPhone
echo(cp is Camera)
echo(cp is MobilePhone)</lang>
{{out}}
<pre>
true
true</pre>
 
=={{header|Objective-C}}==