1 | #include <fstream.hfa> |
---|
2 | |
---|
3 | enum(int) A !{ |
---|
4 | a = 10 |
---|
5 | }; |
---|
6 | |
---|
7 | enum(int) B { |
---|
8 | b = 20 |
---|
9 | }; |
---|
10 | |
---|
11 | enum(int) AB { |
---|
12 | inline A, |
---|
13 | inline B, |
---|
14 | ab = 30 |
---|
15 | }; |
---|
16 | |
---|
17 | enum(int) C { |
---|
18 | c = 40 |
---|
19 | }; |
---|
20 | |
---|
21 | enum(int) D { |
---|
22 | d = 50 |
---|
23 | }; |
---|
24 | |
---|
25 | enum(int) CD { |
---|
26 | inline C, |
---|
27 | inline D, |
---|
28 | cd = 60 |
---|
29 | }; |
---|
30 | |
---|
31 | enum(int) ACD { |
---|
32 | inline A, |
---|
33 | inline CD, |
---|
34 | acd = 70 |
---|
35 | }; |
---|
36 | |
---|
37 | // Note: variable name (cat in this case) cannot be overloaded with those declared in enum, |
---|
38 | // Probably for the same reason as const overloading problem |
---|
39 | // i.e. int identity_t(enum ACD a) would not work as the value(a) is ambigious currently |
---|
40 | int identity_t(enum ACD cat) { |
---|
41 | return value(cat); |
---|
42 | } |
---|
43 | |
---|
44 | int main() { |
---|
45 | // Note: We need to use qualified name syntax even if no ! hidding |
---|
46 | // Because Inline introduce ambiguity on symbols |
---|
47 | sout | "Symbols (enumerator) should have the same values:" |nl; |
---|
48 | sout | "Symbol a: (10) " | value(A.a) | "," | value(AB.a) | "," | value(ACD.a) | nl; |
---|
49 | sout | "Symbol b: (20) " | value(B.b) | "," | value(AB.b) | nl; |
---|
50 | sout | "Symbol ab: (30) " | value(AB.ab) | nl; |
---|
51 | sout | "Symbol c: (40) " | value(C.c) | "," | value(CD.c) | "," | value(ACD.c) | nl; |
---|
52 | sout | "Symbol d: (50) " | value(D.d) | "," | value(CD.d) | "," | value(ACD.d) | nl; |
---|
53 | sout | "Symbol cd: (60) " | value(CD.cd) | "," | value(ACD.cd) | nl; |
---|
54 | sout | "Symbol acd: (70) " | value(ACD.acd) | nl; |
---|
55 | |
---|
56 | sout | "Casting/Upcasting:" | nl; |
---|
57 | sout | "Symbol a: (10) " | value((A)A.a) | "," | value((AB)A.a) | "," | value((ACD)A.a) | nl; |
---|
58 | sout | "Symbol b: (20) " | value((B)B.b) | "," | value((AB)B.b) | nl; |
---|
59 | sout | "Symbol ab: (30) " | value((AB)AB.ab) | nl; |
---|
60 | sout | "Symbol c: (40) " | value((C)C.c) | "," | value((CD)C.c) | "," | value((ACD)C.c) | "," | value((CD)CD.c)| "," | value((ACD)CD.c) | nl; |
---|
61 | sout | "Symbol d: (50) " | value((D)D.d) | "," | value((CD)D.d) | "," | value((ACD)D.d) | "," | value((ACD)CD.d) | nl; |
---|
62 | sout | "Symbol cd: (60) " | value((CD)CD.cd) | "," | value((ACD)CD.cd) | nl; |
---|
63 | sout | "Symbol acd: (70) " | value((ACD)ACD.acd) | nl; |
---|
64 | |
---|
65 | sout | "Function Call:" | nl; |
---|
66 | sout | "Symbol a: (10) " | identity_t(A.a) | "," | identity_t(ACD.a) | nl; |
---|
67 | sout | "Symbol c: (40) " | identity_t(C.c) | "," | identity_t(ACD.c) | nl; |
---|
68 | sout | "Symbol d: (50) " | identity_t(D.d) | "," | identity_t(ACD.d) | nl; |
---|
69 | sout | "Symbol cd: (60) " | identity_t(CD.cd) | "," | identity_t(ACD.cd) | nl; |
---|
70 | sout | "Symbol acd: (70) " | identity_t(ACD.acd) | nl; |
---|
71 | } |
---|