Inheritance/Multiple: Difference between revisions

m
(Added Rust)
Line 324:
=={{header|Elena}}==
ELENA only permits inheritance from one parent class. However, mixins are supported
<lang elena>classsingleton CameraFeature =
{
cameraMsg
= "camera".;
}.
class MobilePhone
{
mobileMsg
= "phone".;
}
class CameraPhone :: MobilePhone
{
dispatch() => CameraFeature.;
}
public program()
{
[
var cp := CameraPhone new. CameraPhone();
console .writeLine(cp .cameraMsg).;
console .writeLine(cp .mobileMsg).
]}</lang>
Alternatively a group object may be created
<lang elena>import system'dynamic.;
 
class CameraFeature
{
cameraMsg
= "camera".;
}
 
Line 360:
{
mobileMsg
= "phone".;
}
 
classsingleton CameraPhone =
{
new() = MobilePhone new; MobilePhone().mixInto(CameraFeature new CameraFeature().);
}.
 
public program()
{
[
var cp := CameraPhone new.new();
 
console .writeLine:(cp .cameraMsg).;
console .writeLine:(cp .mobileMsg).
]}</lang>
 
=={{header|Factor}}==
Anonymous user