C++ inheritance and function overriding
That's so called 'hiding': Y::spray
hides X::spray
.
Add using directive:
class Y : public X
{
public:
using X::spray;
// ...
};
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;