Debian Codegraph @

examples/func/func_overload_multi.ck

raw
1 // func_overload_multi.ck : function overloading
2
3 fun void bar()
4 {
5 <<<1>>>;
6 }
7
8 fun void bar( int i )
9 {
10 <<<2>>>;
11 }
12
13 fun void bar( string s )
14 {
15 <<<3>>>;
16 }
17
18 class X
19 {
20 fun void foo()
21 { <<<"X.foo()">>>; }
22
23 fun void foo( int i )
24 { <<<"X.foo(int)">>>; }
25
26 fun void foo( int a, int b )
27 { <<<"X.foo(int, int)">>>; }
28 }
29
30 class Y extends X
31 {
32 fun void foo()
33 { <<<"Y.foo()">>>; }
34
35 fun void foo( int a, int b )
36 { <<<"Y.foo(int, int)">>>; }
37 }
38
39 Y y;
40 y.foo();
41 y.foo( 1 );
42 y.foo( 1, 2 );
43
44 X x;
45 x.foo( 1, 2 );
46
47 bar();
48 bar(1);
49 bar("a");