Code: Select all
struct PrivateBase { };
struct PublicBase { };
void foo( PrivateBase ) { }
void foo( PublicBase ) { }
struct Derived : PublicBase, private PrivateBase { };
int main()
{
Derived d;
foo( d ); // ambiguous
}Code: Select all
struct PrivateBase { };
void foo( PrivateBase const& ) { }
void bar( PrivateBase const& ) { }
// Many more functions...
template<class PrivateBase>
struct PublicBase { };
template<class PrivateBase>
void foo( PublicBase<PrivateBase> const& x )
{ foo( (PrivateBase const&) x ); }
template<class PrivateBase>
void bar( PublicBase<PrivateBase> const& x )
{ bar( (PrivateBase const&) x ); }
// Many more functions...
struct Derived : PublicBase<PrivateBase>, private PrivateBase { };
int main()
{
Derived d;
foo( d );
bar( d );
// ...
}On second thought, I wonder if the above would work even if the function calls resolved the way I want them to. Any suggestions on how to achieve what I want?


