Connecting Tech Pros Worldwide Help | Site Map

virtual inheritance

Noah Roberts
Guest
 
Posts: n/a
#1: Oct 20 '06
Is there anything that says that if you virtually inherit from one
class you have to virtually inherit from anything you inherit from?

Ron Natalie
Guest
 
Posts: n/a
#2: Oct 20 '06

re: virtual inheritance


Noah Roberts wrote:
Quote:
Is there anything that says that if you virtually inherit from one
class you have to virtually inherit from anything you inherit from?
>
No, if not if I understand your question. You can (and typically do)
have a mix of virtual and non-virtual inheritance.
Salt_Peter
Guest
 
Posts: n/a
#3: Oct 20 '06

re: virtual inheritance


Noah Roberts wrote:
Quote:
Is there anything that says that if you virtually inherit from one
class you have to virtually inherit from anything you inherit from?
What? Can you ask your question with an example?
Your question can be answered ad infinitum and public inheritance is
not the same as virtual public inheritance, either.

I see a misconception here. Inheritance does not mean append or attach.
It means transpose or redesign from scratch. How the redesign takes
place depends on what member functions are virtual and which ones are
virtually overridden or even overloaded.
Also, a ctor and dtor can never be inherited, but a d~tor's vituality
is inherited.

Note that composition is far more common than public inheritance -
which is a strict relationship. If you are trying to circumvent
inheritance of virtual member functions, chances are that the base
class should be a member. Hence the term: composition.

Peter

werasm
Guest
 
Posts: n/a
#4: Oct 20 '06

re: virtual inheritance



Noah Roberts wrote:
Quote:
Is there anything that says that if you virtually inherit from one
class you have to virtually inherit from anything you inherit from?
What are you actually asking - whether virtual iheritance is carried
over??? e.g.

struct Base{};
struct Derived1 : virtual Base{};
struct Derived2 : Derived{};

Derived 2 automatically inherits virtually from Base, as this is
implied because Derived1 does. Derived2 though, does not automatically
inherit virtually from Derived1.

see C++ std 98 par. 10.1/4

Regards,

Werner

Martin Steen
Guest
 
Posts: n/a
#5: Oct 20 '06

re: virtual inheritance


Noah Roberts wrote:
Quote:
Is there anything that says that if you virtually inherit from one
class you have to virtually inherit from anything you inherit from?
>
No. Only methods with the "virtual"-keyword are virtual inherited. All
other methods are normal inherited.

-Martin
Noah Roberts
Guest
 
Posts: n/a
#6: Oct 20 '06

re: virtual inheritance



Ron Natalie wrote:
Quote:
Noah Roberts wrote:
Quote:
Is there anything that says that if you virtually inherit from one
class you have to virtually inherit from anything you inherit from?
No, if not if I understand your question. You can (and typically do)
have a mix of virtual and non-virtual inheritance.
Yes, you understand my question. I'm getting very strange results I
hadn't gotten until I tried virtual inheritance on one class. It is
affecting a different parent. I didn't think virtual inheritance
required that but it was worth asking because I have no idea what is
going on.

Thread on that is titled "Anyone seen anything like this" or something
like that. I'll be trying to reproduce it in a simple program today if
I can.

Closed Thread