《》《》《》《》 请问如何在继承类中使用操作符重载? 《》《》《》《》
class AA
{
public:
AA& operator =(AA& ptr){t1 = ptr.t1; return *this;}
int t1;
}
class BB : public AA
{
public:
BB& operator =(BB& ptr){t2 = ptr.t2; return *this;}
int t2;
}
我在使用的时候发现,当我声明BB对象a,b, a=b操作后基类AA中的变量没有改变,难道操作符重载不支持继承吗?
BB a, b;
a=b;
t2改变,t1没有改变:(
请教各位该怎么写