The setup you have is a classic example of an overriding function hiding other inherited overloads.
When a function is overridden in a derived class, that overriding function hides all the other overloads from the base class. Overload resolution comes after selecting the name, so once PrintString
is determined to refer to Print::PrintString
, it will never consider PrintBase::PrintString
, even if the former does not accept the arguments being supplied and the latter would.
The most straightforward way is to bring in the inherited, but not overridden names into the derived class with a using
declaration:
class Print: public PrintBase
{
public:
virtual void PrintChar(wchar_t ch) override;
using PrintBase::PrintChar;
virtual void PrintString(const wstring& str) override;
using PrintBase::PrintString;
};
I don't believe calling PrintChar('x')
through a Print
object actually calls the inline overload. What it would really do is initialise the wchar_t
from the char
you pass in. Is it possible it just does the same thing as the inline version would in your case?