Can a class overload methods that also exist in the publicly inherited interface? It seems like this is unambiguous and useful, but compilers (VC, Intel, GCC) all complain,
When you declare a method in the subclass with the same name but a different signature, it actually hides the version from the parent.
You could refer to it specifically as Bound::rebound(...) or use the using keyword.
See here
You can do three things:
Add a using
in the Node
declaration:
using Bound::rebound;
void rebound() { rebound(left, right); }
Use the Bound namespace:
void rebound() { Bound::rebound(left, right); }
Delegate the implementation to the base class (if this is done in the header, there shouldn't be any penalty thanks to inlining):
void rebound(const Bound *a, const Bound *b) { Bound::rebound(a, b); };
void rebound() { rebound(left, right); }
More info: https://isocpp.org/wiki/faq/strange-inheritance#overload-derived
This is called hiding the parent member function. You can explicitly call it (by Bound::rebound(left, right)
as @Ates Goral said) or you can add a using Bound::rebound
in your Node
class definition.
See http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.9 for more info.