21 /* 重载"(int)a" */
22 operator int() { return dat; }
23
24 /* 重载"(A)a" */
25 operator A() {
26 A temp = dat;
27 return temp;
28 }
29
30 private:
31 int dat;
32 };
33
34
35 int main()
36 {
37 X stuff = 37;
38 A more = 0;
39 int hold;
40
41 hold = stuff; // convert X::stuff to int
42 std::cout << hold << std::endl;
43
44 more = stuff; // convert X::stuff to A::more
45 std::cout << more << std::endl; // convert A::more to int
46
47 return 0;
48 }
49