A question about inheritance

V

vineoff

First, think I'm having an abstract class

class C { public: virtual void f(); };

What is the difference between these two ways:

class D : public C { ... }
and
class D : public virtual C { ... }

I've tried to search from google with no luck. Examples are always in
first form, without keyword 'virtual' in inheritance list.

Is this too complicated to explain here?

Thanks in advance.

~ vineoff
 
T

TIT

vineoff sade:
First, think I'm having an abstract class

class C { public: virtual void f(); };

What is the difference between these two ways:

class D : public C { ... }
and
class D : public virtual C { ... }

I've tried to search from google with no luck. Examples are always in
first form, without keyword 'virtual' in inheritance list.


Have you tried googling for "virtual inheritance"?
I get several direct results on the topic, including:

http://www.parashift.com/c++-faq-lite/multiple-inheritance.html

TIT
 
V

Victor Bazarov

vineoff said:
First, think I'm having an abstract class

class C { public: virtual void f(); };

No, you're having a brain-o. This is not an abstract class.
What is the difference between these two ways:

class D : public C { ... }
and
class D : public virtual C { ... }

For 'D', none.
I've tried to search from google with no luck. Examples are always in
first form, without keyword 'virtual' in inheritance list.

Is this too complicated to explain here?

No, but your book can do it better. What book are you reading that
does not explain virtual inheritance?

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top