blob: 8fda748b8ebe840d2a6e7c39adb9e4401085f70b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
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;
}
|