Reputation: 24760
If I overload operator*(float s)
in a Base class (and I do not make it virtual) and then in a Derived class I overload operator*(mat4 m)
can I reasonably expect that the Derived class will then respond to both operator overloads?
I assume that an operator overload is like any other function: if it is not virtual and not overridden, then the Derived class has access to it in addition to any other overloads of that function/operator that are unique to the Derived class.
Of course, if it is not virtual but the Derived class also defined operator*(float s)
then it would effectively be called only if the Derived was accessed via a Derived*
pointer, otherwise, the base class version would be called even on the Derived class, correct?
Upvotes: 0
Views: 105
Reputation: 272507
I assume that an operator overload is like any other function: if it is not virtual and not overridden, then the Derived class has access to it in addition to any other overloads of that function/operator that are unique to the Derived class.
Just as with normal member functions, the overload in the derived class hides the original, unless you use using
.
Upvotes: 1