C++ inheritance and function overriding

The term used to describe this is “hiding”, rather than “overriding”. A member of a derived class will, by default, make any members of base classes with the same name inaccessible, whether or not they have the same signature. If you want to access the base class members, you can pull them into the derived class with a using declaration. In this case, add the following to class Y:

using X::spray;

Leave a Comment