Thread: name lookup ambiguity

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    name lookup ambiguity

    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

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >even if we can not access directly the private method of base class?
    Correct. Visibility and accessibility are two different things.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks Prelude,


    Question answered.

    Quote Originally Posted by Prelude View Post
    >even if we can not access directly the private method of base class?
    Correct. Visibility and accessibility are two different things.

    regards,
    George

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. search file for values in lookup table
    By sixstringsgaret in forum C Programming
    Replies: 12
    Last Post: 03-04-2008, 04:23 PM
  2. Lookup in lists
    By agentsmith in forum C Programming
    Replies: 1
    Last Post: 12-07-2007, 02:14 PM
  3. gethostbyaddr() reverse lookups failing (???)
    By Uncle Rico in forum C Programming
    Replies: 9
    Last Post: 08-19-2005, 09:22 AM
  4. DNS lookup?
    By Devil Panther in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-17-2004, 07:05 AM
  5. Lookup Table Reference???
    By gvector1 in forum C++ Programming
    Replies: 3
    Last Post: 04-02-2003, 05:03 PM