disambiguate static multiply inherited class functions

W

wes

Hi,
Is there anyway to disambiguate multiply inherited static class
functions?

template<T>
class A
{
static doit() {}
}

class B : public A<B>
{

}

class C : public A<C>, public B
{

}

C::doit() <----error ambiguous!

any way to specify which C::doit() function gets called?
 
P

Piyo

wes said:
any way to specify which C::doit() function gets called?

I first tried virtual inheritance but I forgot that
class A<B> and class A<C> are still distinct classes and
thus does not help. The only way to disambiguate then is
to fully qualify what you want to call. See how in main,
I can call them directly without ambiguity.

HTH

-------------------------------------
template<typename T>
class A
{
public:
static T doit() { return T(); }
};

class B : public A<B>
{
public:
};

class C : public A<C>, public B
{
public:
};

int
main()
{
A<C>::doit();
B::doit();
//C::doit();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top