#include enum(int) A !{ a = 10 }; enum(int) B { b = 20 }; enum(int) AB { inline A, inline B, ab = 30 }; enum(int) C { c = 40 }; enum(int) D { d = 50 }; enum(int) CD { inline C, inline D, cd = 60 }; enum(int) ACD { inline A, inline CD, acd = 70 }; // Note: variable name (cat in this case) cannot be overloaded with those declared in enum, // Probably for the same reason as const overloading problem // i.e. int identity_t(enum ACD a) would not work as the value(a) is ambigious currently int identity_t(enum ACD cat) { return value(cat); } int main() { // Note: We need to use qualified name syntax even if no ! hidding // Because Inline introduce ambiguity on symbols sout | "Symbols (enumerator) should have the same values:" |nl; sout | "Symbol a: (10) " | value(A.a) | "," | value(AB.a) | "," | value(ACD.a) | nl; sout | "Symbol b: (20) " | value(B.b) | "," | value(AB.b) | nl; sout | "Symbol ab: (30) " | value(AB.ab) | nl; sout | "Symbol c: (40) " | value(C.c) | "," | value(CD.c) | "," | value(ACD.c) | nl; sout | "Symbol d: (50) " | value(D.d) | "," | value(CD.d) | "," | value(ACD.d) | nl; sout | "Symbol cd: (60) " | value(CD.cd) | "," | value(ACD.cd) | nl; sout | "Symbol acd: (70) " | value(ACD.acd) | nl; sout | "Casting/Upcasting:" | nl; sout | "Symbol a: (10) " | value((A)A.a) | "," | value((AB)A.a) | "," | value((ACD)A.a) | nl; sout | "Symbol b: (20) " | value((B)B.b) | "," | value((AB)B.b) | nl; sout | "Symbol ab: (30) " | value((AB)AB.ab) | nl; 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; sout | "Symbol d: (50) " | value((D)D.d) | "," | value((CD)D.d) | "," | value((ACD)D.d) | "," | value((ACD)CD.d) | nl; sout | "Symbol cd: (60) " | value((CD)CD.cd) | "," | value((ACD)CD.cd) | nl; sout | "Symbol acd: (70) " | value((ACD)ACD.acd) | nl; sout | "Function Call:" | nl; sout | "Symbol a: (10) " | identity_t(A.a) | "," | identity_t(ACD.a) | nl; sout | "Symbol c: (40) " | identity_t(C.c) | "," | identity_t(ACD.c) | nl; sout | "Symbol d: (50) " | identity_t(D.d) | "," | identity_t(ACD.d) | nl; sout | "Symbol cd: (60) " | identity_t(CD.cd) | "," | identity_t(ACD.cd) | nl; sout | "Symbol acd: (70) " | identity_t(ACD.acd) | nl; }