摘要: operaotr除了用于重载=、>、<之类的东西外,还有以下用途1. 类型转换class T{public: operator int() const { return 5; }};上述的代码,为T类提供了转换为int的能力。默认隐式使用。注意使用了const,保证可靠性。T t = T();int i = t;cout << i << endl; // 输出52. 赋值运算重载class T{ public: int _val; T(int val): _val(val){} void operator=(const T& t) ... 阅读全文
posted @ 2012-04-24 18:14 斯啦丝拉 阅读(306) 评论(0) 推荐(0) 编辑