namespace; include rt; // two tagged enums may share a member name: each keeps its own fields and tag enum a { item { int x; }, other }; enum b { item { int y; }, nope }; o3 int tot(a* p, int n) { int t = 0; for (int i = 0; i < n; i++) { switch (p) { case item(x): t += x; case other: t += 100; } } return t; } int main() { a* p = a.item(3); b* q = b.item(8); rt.put_n(p.item_x); rt.put_c(32); rt.put_n(q.item_y); rt.put_c(32); rt.put_n(tot(p, 4)); rt.put_c(10); rt.free(d*p); rt.free(d*q); return 0; }