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;
}
Printable View
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;
}
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.Quote:
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.