C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 08-10-2001, 12:07 AM   #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
kitten is offline   Reply With Quote
Old 08-10-2001, 04:39 AM   #2
Unregistered
Guest
 
Posts: n/a
>>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,
  Reply With Quote
Old 08-10-2001, 04:45 AM   #3
Ted_
Guest
 
Posts: n/a
Forgive the unregistered response. I was unaware my user name would post as "unregistered."

My apologies,

Ted
  Reply With Quote
Old 08-10-2001, 10:04 PM   #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)
cozman is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple inheritance: casting yields different address dwks C++ Programming 16 06-08-2009 03:03 PM
Abnormal Program Termination when executed from C:\Program Files\... m37h0d Windows Programming 48 09-26-2008 03:45 AM
Virtual function and multiple inheritance George2 C++ Programming 68 02-13-2008 01:15 AM
C++ XML Class edwardtisdale C++ Programming 0 12-10-2001 11:14 PM
Exporting Object Hierarchies from a DLL andy668 C++ Programming 0 10-20-2001 01:26 PM


All times are GMT -6. The time now is 10:44 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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