how we can avoid ambiguty in multiple inheritance

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sandip kalbhile
    New Member
    • Jul 2010
    • 2

    how we can avoid ambiguty in multiple inheritance

    //example
    Code:
    class a
    {
    public: int a;
    a=10;
    }
    class b
    {
    
    public: int a;
    a=5;
    }
    class c:a,b
    {
    int d;
    
    //how we can print vallue of a as 10 by avoiding ambiguty
    
    }
    void main()
    {
    c c1;
    cout<<c1.a;
    }
    Last edited by Niheel; Jul 26 '10, 05:47 PM. Reason: please use code tags to display code
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Which a do you want? a::a or b::a?

    C++ uses the scope resolution operator to avoid ambiguity.

    Comment

    Working...