Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Virtual Inheritance

Reply
Thread Tools

Virtual Inheritance

 
 
news-east
Guest
Posts: n/a
 
      11-28-2004
It's probably a silly question, but if there exists a base class A, and from
it derives classes B and C, and a further class D multiply-inherits from B
and C. Let's say B derives virtually from A, and C derives non-virtually.

What should the compiler behaviour be on instantiation of an object of type
D* ?



Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      11-28-2004
"news-east" <Aidend@None> wrote...
> It's probably a silly question, but if there exists a base class A, and
> from it derives classes B and C, and a further class D multiply-inherits
> from B and C. Let's say B derives virtually from A, and C derives
> non-virtually.
>
> What should the compiler behaviour be on instantiation of an object of
> type D* ?


An object of type D* is a pointer. Instantiating it does not depend on the
base classes of D (and their base classes, and so on).

In case you made a typo and didn't intend to write D*, then there should be
two objects of class A in a D. One that comes from B and the other from C.
The Standard specifies so in 10.1/4.

V


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual inheritace -- when one inheritance of the base is virtual andthe other isn't. pauldepstein@att.net C++ 1 03-14-2009 03:45 PM
virtual inheritance and virtual function. Ashwin C++ 2 08-01-2006 12:48 PM
mul. inheritance & overloading operator new/delete solved by virtual base inheritance? cppsks C++ 0 10-27-2004 07:49 PM
Should 'public virtual' always become 'private virtual'? & using private inheritance qazmlp C++ 19 02-04-2004 12:37 AM
Private access modifier and Inheritance (Inheritance implementation in Java) maxw_cc Java 1 12-21-2003 11:38 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57