Multiple inheritance allows to specify that one  class is a subclass of several other classes.

Some languages allow multiple inheritance for arbitrary classes,   others restrict it to interfaces,   some don't allow it at all.



Task

Write two classes (or interfaces) Camera and MobilePhone,   then write a class CameraPhone which is both a Camera and a MobilePhone.

There is no need to implement any functions for those classes.




 
 
\ define class camera with method say:
:class camera
 :m say: ." camera " ;m
;class
 
\ define class phone with method say:
:class phone
 :m say: ." phone " ;m
;class
 
\ define cameraPhone phone with method say:
\ class cameraPhone inherits from both class
\ camera and class phone
:class cameraPhone super{ camera phone }
 :m say: self say: \ method conflicts in superclasses
                   \ are resolved by left-to-right order
                   \ so self say: will call the say: method
                   \ from class camera
    super> phone say: \ super> phone is used to direct
                      \ this say: method to use the
                      \ method from class phone
 ;m
;class
 
cameraPhone cp \ instantiate a cameraPhone object named cp
 
cp say: \ send the say: message to cp
 
\ output:
camera phone
 