repo.or.cz
/
chuck-blob.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
*** empty log message ***
[chuck-blob.git]
/
v2
/
test
/
p115.ck
blob
1fd86cd05c923266958b080780831512e30b1058
1
//virtual table
2
3
class Top {
4
function int topValue() {
5
return 1;
6
}
7
}
8
9
class Bottom extends Top {
10
function int bottomValue() {
11
return 2;
12
}
13
}
14
15
Top t;
16
Bottom b;
17
b @=> Top @ b2t;
18
19
20
<<<"Bottom Class">>>;
21
<<<b.topValue()>>>;
22
<<<b.bottomValue()>>>;
23
24
<<<"Top Class">>>;
25
<<<t.topValue()>>>;
26
27
<<<"Bottom Cast to Top">>>;
28
<<<b2t.topValue()>>>;
29
30
if( b.topValue() == 1 && b.bottomValue() == 2 && t.topValue() == 1 && b2t.topValue() == 1 )
31
<<<"success">>>;