Inheritance/Single: Difference between revisions
m
→{{header|Phix}}: oops
m (→{{header|OCaml}}: 5*s->1) |
m (→{{header|Phix}}: oops) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1,677:
=={{header|Perl}}==
<syntaxhighlight lang="perl">
package Animal;
#functions go here...
1;
1;</syntaxhighlight>▼
use Animal;
@ISA = qw( Animal );
#functions go here...
1;
1;</syntaxhighlight>▼
use Animal;
@ISA = qw( Animal );
#functions go here...
1;
1;</syntaxhighlight>▼
use Dog;
@ISA = qw( Dog );
#functions go here...
1;
1;</syntaxhighlight>▼
use Dog;
@ISA = qw( Dog );
#functions go here...
1;
# The same using the [http://search.cpan.org/perldoc?MooseX::Declare MooseX::Declare] module:
class Animal {
Line 1,723 ⟶ 1,724:
class Collie extends Dog {
# methods go here...
}
=={{header|Phix}}==
{{libheader|Phix/Class}}
Add (private|public) fields and methods as needed. Make Animal and Dog abstract (ie use "abstract class") to prevent instantiation.
<!--
without js -- (class)
class Animal
private string species
end class
class Dog extends Animal
public procedure bark()
puts(1,"woof\n")
end procedure
end class
class Lab extends Dog end class
class Collie extends Dog end class
class Cat extends Animal end class
=={{header|PHP}}==
Line 2,088 ⟶ 2,091:
=={{header|Self}}==
Self is a class-free, object-oriented language, and as such, it uses prototypal inheritance instead of classical inheritance. This is an example of the relevant excerpts from a Self transporter fileout. Normally the object tree would be built and navigated within the graphical Self environment.
<syntaxhighlight lang="self"
animal = ()
collie = (| parent* = dog |)
=={{header|Sidef}}==
|