Just add
Quote:
>
using Parent<A>::doit;
using Parent<B>::doit;
>
here and everything compiles.
|
Ah, I knew there'd be an easier way, thanks for that. Unfortunately it
won't be the tidiest solution for my problem - if each class inherits a
bunch of functions, that could be quite a lot of "using" statements.
I've come up with somewhat of a hack to get around it, in the form of a
new class that will only be inherited once:
template <class TMain>
class ParentHandler
{
public:
template <class TParent>
void doit2(const TParent& param)
{
TMain *p = static_cast<TMain *>(this);
return p->Parent<TParent>::doit(param);
}
};
It can then be used like this:
class Child: public Parent<A>, public Parent<B>,
public ParentHandler<Child>
{
};
And then it removes the ambiguity when used, regardless of how many
Parent classes are inherited (and no code changes are required when
adding more inherited objects):
c.doit2(a); // call Parent<A>.doit()
c.doit2(b); // call Parent<B>.doit()
Granted it's somewhat ugly, but my emphasis here is to make my class
easy to use, not necessarily easy to write :-)
Cheers,
Adam.