Inheritance 13
This commit is contained in:
parent
d8ac625429
commit
848c846e09
12 changed files with 117 additions and 7 deletions
36
test/super.lox
Normal file
36
test/super.lox
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
class Doughnut{
|
||||
cook(){
|
||||
print "Fry until golden brown.";
|
||||
}
|
||||
}
|
||||
|
||||
class BostonCream < Doughnut{
|
||||
cook(){
|
||||
super.cook();
|
||||
print "Pipe full of custard and coat with chocolate.";
|
||||
}
|
||||
}
|
||||
|
||||
BostonCream().cook();
|
||||
|
||||
|
||||
class A{
|
||||
method(){
|
||||
print "A method";
|
||||
}
|
||||
}
|
||||
|
||||
class B < A{
|
||||
method(){
|
||||
print "B method";
|
||||
}
|
||||
test(){
|
||||
super.method();
|
||||
}
|
||||
}
|
||||
|
||||
class C < B{}
|
||||
|
||||
C().test();
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue