Inheritance/Multiple: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 66:
}CameraPhone;
</lang>
 
=={{header|C++}}==
<lang cpp>class Camera
{
// ...
};
 
class MobilePhone
{
// ...
};
 
class CameraPhone:
public Camera,
public MobilePhone
{
// ...
};</lang>
 
=={{header|C sharp|C#}}==
Line 103 ⟶ 85:
// ...
}</lang>
 
=={{header|C++}}==
<lang cpp>class Camera
{
// ...
};
 
class MobilePhone
{
// ...
};
 
class CameraPhone:
public Camera,
public MobilePhone
{
// ...
};</lang>
 
=={{header|Clojure}}==
Line 396:
console.writeLine(cp.mobileMsg)
}</lang>
 
=={{header|F_Sharp|F#}}==
A class can only inherit from one other class, but it can implement any number of interfaces.
 
<lang fsharp>type Picture = System.Drawing.Bitmap // (a type synonym)
 
// an interface type
type Camera =
abstract takePicture : unit -> Picture
 
// an interface that inherits multiple interfaces
type Camera2 =
inherits System.ComponentModel.INotifyPropertyChanged
inherits Camera
 
// a class with an abstract method with a default implementation
// (usually called a virtual method)
type MobilePhone() =
abstract makeCall : int[] -> unit
default x.makeCall(number) = () // empty impl
 
// a class that inherits from another class and implements an interface
type CameraPhone() =
inherit MobilePhone()
interface Camera with
member x.takePicture() = new Picture(10, 10)</lang>
 
=={{header|Factor}}==
Line 462 ⟶ 488:
' other stuff
End Type</lang>
 
=={{header|F_Sharp|F#}}==
A class can only inherit from one other class, but it can implement any number of interfaces.
 
<lang fsharp>type Picture = System.Drawing.Bitmap // (a type synonym)
 
// an interface type
type Camera =
abstract takePicture : unit -> Picture
 
// an interface that inherits multiple interfaces
type Camera2 =
inherits System.ComponentModel.INotifyPropertyChanged
inherits Camera
 
// a class with an abstract method with a default implementation
// (usually called a virtual method)
type MobilePhone() =
abstract makeCall : int[] -> unit
default x.makeCall(number) = () // empty impl
 
// a class that inherits from another class and implements an interface
type CameraPhone() =
inherit MobilePhone()
interface Camera with
member x.takePicture() = new Picture(10, 10)</lang>
 
=={{header|Go}}==
Line 621:
myPhone call // --> "Calling home"</lang>
In Io each object has an internal list of prototype objects it inherits from. You can add to this list with <code>appendProto</code>.
 
=={{header|Ioke}}==
<lang ioke>Camera = Origin mimic
Line 680 ⟶ 681:
 
{{omit|Julia}}
 
 
 
 
=={{header|Julia}}==
Line 1,096 ⟶ 1,094:
(*functions go here...*)
end</lang>
 
 
=={{header|Oforth}}==
Line 1,204 ⟶ 1,201:
# methods ...
}</lang>
 
=={{header|Perl 6}}==
 
{{works with|Rakudo|2012.06}}
<lang perl6>class Camera {}
class MobilePhone {}
class CameraPhone is Camera is MobilePhone {}
 
say CameraPhone.^mro; # undefined type object
say CameraPhone.new.^mro; # instantiated object</lang>
{{out}}
<pre>CameraPhone() Camera() MobilePhone() Any() Mu()
CameraPhone() Camera() MobilePhone() Any() Mu()</pre>
 
The <tt>.^mro</tt> is not an ordinary method call,
but a call to the object's metaobject
that returns the method resolution order for this type.
 
=={{header|Phix}}==
Line 1,308 ⟶ 1,288:
class CameraPhone : Camera, MobilePhone {}
</lang>
 
 
=={{header|PureBasic}}==
Line 1,346 ⟶ 1,325:
;; implement methods here
))</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
 
{{works with|Rakudo|2012.06}}
<lang perl6>class Camera {}
class MobilePhone {}
class CameraPhone is Camera is MobilePhone {}
 
say CameraPhone.^mro; # undefined type object
say CameraPhone.new.^mro; # instantiated object</lang>
{{out}}
<pre>CameraPhone() Camera() MobilePhone() Any() Mu()
CameraPhone() Camera() MobilePhone() Any() Mu()</pre>
 
The <tt>.^mro</tt> is not an ordinary method call,
but a call to the object's metaobject
that returns the method resolution order for this type.
 
=={{header|Ring}}==
Line 1,431 ⟶ 1,428:
define: #MobilePhone.
define: #CameraPhone &parents: {Camera. MobilePhone}.</lang>
 
=={{header|Swift}}==
Like Objective-C, Swift does not allow multiple inheritance. However, you can conform to multiple protocols.
Line 1,454 ⟶ 1,452:
superclass Camera MobilePhone
}</lang>
 
 
=={{header|zkl}}==
10,333

edits