class Base
{
};
class Deriv : private Base
{
public:
operator Base & ()
{
return *this;
}
};
So I got this simple code. I'd like to make the implicit base conversion operator accessible in the deriv class. The solution above doesn't work because the compiler will always use the default operation (slicing) (see C++ Define Conversion to Base Class) BUT in my case I just want to make it accessible, not overloaded. Something like
public:
using operator Base &();
it seems not possible, but I wonder why and if there are other solutions (aside of making an explicit function).
Please don't ask me why I'm doing this, I'm just looking if there's a solution to this issue I found for a very specific scenario.