First, polymorphism works with both references and pointers. And
operator overloading works with references. So there's no problem at
that level.
There is a potential problem with binary operators. Direct language
support for polymorphism on an operator only works on the left hand
operand. Where as for something like binary +
, one logically would
expect double dispatch. While this can be implemented, it is somewhat
more complex, especially if the hierarchies are open.
For operators like binary +
, which normally return a new object, there
is also the question of the return type. Typically, this can't be a
reference, since there is no object with an appropriate type to refer
to. Patterns like the letter-envelop idiom have been developed to deal
with this, but they aren't necessarily simple, and they often have very
significant run-time overhead. Or the overloaded operator returns a
special type, which only saves its arguments, and knows how to calculate
the value with the correct type when requested.