有一类这样的:运营商[]重载
class X {
public:
...
private:
int changeable[3];
int unchangeable[3];
};
这是其理想的用法:
X x;
x[0] = 1; // here changeable[0] should be used
a = x[0]; // here unchangeable[0] should be used
是否有限定class X
operator[]
以实施的方法吗?
您可以实现第一种情况下,可以实现第二种情况但不能两者一起 – Gaim 2010-09-30 21:24:01
他可以重载运营商,它可能会选择基于上下文。 – JSchlather 2010-09-30 21:26:58