3 struct IA { void hasIA() {} };
4 struct IB { void hasIB() {} };
5 struct IC { void hasIC() {} };
6 struct ID { void hasID() {} };
7 struct IE { void hasIE() {} };
8 struct I1 { void hasI1() {} };
9 struct I2 { void hasI2() {} };
10 struct I3 { void hasI3() {} };
13 datatype T = A() : IA with { void get_A(); }
14 | B() : IB with { void get_B(); }
15 | C() : IC with { void get_C(); }
16 | D() : ID with { void get_D(); }
22 datatype T2 : IE = E() with { void get_E(); }
29 refine T : I1 :: collectable { virtual std::ostream& print(std::ostream&) = 0; }
30 and A, B, C, D : I2 { std::ostream& print(std::ostream&); }
31 and T2 : I3 :: collectable { virtual std::ostream& print(std::ostream&); }
34 instantiate datatype T, T2;
36 void classof A::get_A() { hasIA(); hasI1(); hasI2(); }
37 void classof B::get_B() { hasIB(); hasI1(); hasI2(); }
38 void classof C::get_C() { hasIC(); hasI1(); hasI2(); }
39 void classof D::get_D() { hasID(); hasI1(); hasI2(); }
40 void classof E::get_E() { hasIE(); hasI3(); }
42 std::ostream& classof A::print(std::ostream& s) { return s << "A"; }
43 std::ostream& classof B::print(std::ostream& s) { return s << "B"; }
44 std::ostream& classof C::print(std::ostream& s) { return s << "C"; }
45 std::ostream& classof D::print(std::ostream& s) { return s << "D"; }
46 std::ostream& classof E::print(std::ostream& s) { return s << "E"; }
51 x->print(cout) << '\n';
54 y->print(cout) << '\n';