Debian Codegraph @

src/test/01-Basic/36.ck

raw
1 // 36.ck : function overloading across inheritance, with overriding
2
3 // base calss
4 class X
5 {
6 fun void foo( int a )
7 { <<<a>>>; }
8
9 fun void foo( int a, int b )
10 { <<<a+b>>>; }
11 }
12
13 // class Y
14 class Y extends X
15 {
16 // override X's foo( int )
17 fun void foo( int a )
18 { <<<a+1>>>; }
19
20 fun void foo( int a, int b )
21 { <<<a+b+1>>>; }
22 }
23
24 // class Z
25 class Z extends Y
26 {
27 // override Y's foo( int, int )
28 fun void foo( int a, int b )
29 { <<<"success">>>;}
30 }
31
32 // instantiate a Z
33 Z x;
34
35 // call the foo
36 x.foo(3,5);