Multiple virtual inheritance

This is a discussion on Multiple virtual inheritance within the C++ Programming forums, part of the General Programming Boards category; Well I had a question in my mind so I can put it here as well... By the topic I ...

  1. #1
    Registered User kitten's Avatar
    Join Date
    Aug 2001
    Posts
    109

    Talking Multiple virtual inheritance

    Well I had a question in my mind so I can put it here as well...

    By the topic I mean structure like this:

    class A

    class B1 : virtual public A
    class B2 : virtual public A

    class C : public B1, public B2

    I've been familiar to multiple virtual inheritance a while, and I've never run into any situation where it would've been needed. There has always been a simpler and working solution. Nor I've never thought of any possible situation where it'd been come handy. So could somebody give me an example or ideas where multiple virtual inheritance is needed.

    No code needed at all, just ideas and descriptions. Thanks.
    Making error is human, but for messing things thoroughly it takes a computer

  2. #2
    Unregistered
    Guest
    >>could somebody give me an example or ideas where multiple virtual inheritance is needed.

    iostream uses multiple inheritance and virtual base classes. Iostream is derived from both istream and ostream, and both istream and ostream are derived from ios.

    class ios { . . . }; // base class
    class istream : virtual public ios { . . . }; // derived
    class ostream : virtual public ios { . . . }; // derived
    class iostream : public istream, public ostream { . . . }; // derived

    I can't say such a thing is ever needed, but it is a tool with an appropriate built-in safegaurd.

    hth,

  3. #3
    Ted_
    Guest
    Forgive the unregistered response. I was unaware my user name would post as "unregistered."

    My apologies,

    Ted

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    403

    i find that i've gone to far

    if i'm ever doing something close to this i usually turn around.. in my opinion i'm just destroying the beauty of encapsulation. (at least for the kinda stuff i do)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 06-08-2009, 04:03 PM
  2. Replies: 48
    Last Post: 09-26-2008, 04:45 AM
  3. Virtual function and multiple inheritance
    By George2 in forum C++ Programming
    Replies: 68
    Last Post: 02-13-2008, 01:15 AM
  4. C++ XML Class
    By edwardtisdale in forum C++ Programming
    Replies: 0
    Last Post: 12-10-2001, 11:14 PM
  5. Exporting Object Hierarchies from a DLL
    By andy668 in forum C++ Programming
    Replies: 0
    Last Post: 10-20-2001, 02:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21