Thread: Multiple Inheritance Ambiguity

  1. #16
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    I'm just reading this stuff totally spelled out in Effective C++ second edition. Check out Item 43: Use multiple inheritance judiciously.

  2. #17
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    Fordy, thanks. What you're saying is that you can't just call fb.Sing(); because the compiler doesn't know which to call? That solves that I suppose.

    side: TK, if you're not an OOP guy, why do you keep responding on clearly OOP topics and then validating it with "... but then I'm not an OOP guy"

  3. #18
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by FillYourBrain
    Fordy, thanks. What you're saying is that you can't just call fb.Sing(); because the compiler doesn't know which to call? That solves that I suppose.
    Yup...that's how I see it.....

  4. #19
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Try using a scope identifier:

    Derived Obj;
    Obj.Base1::func(...);

    What is this? Are you telling me that you can't put 1 and 1 together? lol.

  5. #20
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    read my initial question. it deals with how the compiler resolves ambiguity. It's NOT asking for a way around the ambiguity. damn you're dense.

  6. #21
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    No but honestly check out Item 43 in Effective C++ second edition. It gives a long description. I ofcourse didn't see this until after I answered the question correctly.

    I'm not a C++er. I'm a Cer.

  7. #22
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    Heres an example I was given in my lectures. Its a complex issue but this gives you an idea how to avoid multiple copies being inherited.
    Code:
    class GrandMa
    {
    protected:
       int value;
    };
    
    class Son : virtual public GrandMa
    {
       Son( )
    };
    
    class Daughter : virtual public GrandMa
    {
       Daughter( )
    };
    
    
    class GrandChild : public Son, public Daughter
    {
       GrandChild( );   //now only has 1 copy of value
    }
    Now GrandMa is termed a virtual base class. I'm not sure which copy is inherited, like I say its a complex issue which can usually be avoided. Hope that helps though
    Couldn't think of anything interesting, cool or funny - sorry.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 06-08-2009, 03:03 PM
  2. references and multiple inheritance - incompatible?
    By m37h0d in forum C++ Programming
    Replies: 11
    Last Post: 09-03-2008, 02:35 PM
  3. Multiple inheritance in C#
    By DavidP in forum C# Programming
    Replies: 1
    Last Post: 06-27-2008, 04:41 PM
  4. Multiple Inheritance - Size of Classes?
    By Zeusbwr in forum C++ Programming
    Replies: 10
    Last Post: 11-26-2004, 09:04 AM
  5. Multiple virtual inheritance
    By kitten in forum C++ Programming
    Replies: 3
    Last Post: 08-10-2001, 10:04 PM