My problem is that the operator+=(Base&) is called instead of the other one. Any suggestions?Code:Base& Base::operator+=(Base& e) { } Base& Base::operator+=(Derived& e) { } int main() { Base *x, z; Derived y; z += y; }
My problem is that the operator+=(Base&) is called instead of the other one. Any suggestions?Code:Base& Base::operator+=(Base& e) { } Base& Base::operator+=(Derived& e) { } int main() { Base *x, z; Derived y; z += y; }
Last edited by ygfperson; 05-03-2003 at 03:56 PM.
it's doing what its supposed to?
Sorry, typo. It's going to Base&, but i want it to accept Derived&. I've edited the question accordingly.Originally posted by Jamsan
it's doing what its supposed to?
try casting it perhaps ?
No luck.
BTW, my example isn't technically accurate... I dereferenced a Base pointer to a Derived object, but the rest is the same.
Casting doesn't work because it's already Derived&. I tried dynamic_cast<Derived&>() but no luck either.