name lookup ambiguity

Joined
Feb 12, 2008
Messages
108
Reaction score
0
Hello everyone,


The following code will result in compile error below is because of private method of base class is also considered into name lookup, even if we can not access directly the private method of base class?

error C2385: ambiguous access of 'foo'

Code:
class Base
{
private:
     void foo() {}
public:
     void bar() {}
};

struct Mixin { void foo() {} };

class Derived: public Base, public Mixin
{
public:
     void bar() { foo(); }   // Uh oh.
};

int main()
{
     Derived().bar();
}


thanks in advance,
George
 

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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top