【发布时间】:2011-02-25 19:43:07
【问题描述】:
我已经重载了 + 和 += 运算符,具有以下签名:
// within A's header file..
A operator+(const B &p);
A &operator+=(B &p);
为什么当我尝试使用 += 运算符时,我收到编译器错误消息
“A*”类型的无效操作数和 "B*" 转二进制 'operator+'。
an_a; // an instance of class A
B *a_b = new B(some_parameters);
an_a += a_b;
【问题讨论】: