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