name lookup ambiguity

Discussion in 'C Programming' started by George2, Mar 17, 2008.

  1. George2

    George2

    Joined:
    Feb 12, 2008
    Messages:
    108
    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
    George2, Mar 17, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Greg
    Replies:
    0
    Views:
    550
  2. ciaran.mchale@iona.com
    Replies:
    0
    Views:
    558
    ciaran.mchale@iona.com
    Nov 30, 2005
  3. Stanimir Stamenkov
    Replies:
    1
    Views:
    490
    Stanimir Stamenkov
    Jan 5, 2006
  4. Mark Turney
    Replies:
    11
    Views:
    4,266
    dibeas
    Nov 13, 2006
  5. root
    Replies:
    2
    Views:
    556
    valtih1978
    Jul 12, 2012
Loading...

Share This Page