By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,513 Members | 1,810 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,513 IT Pros & Developers. It's quick & easy.

A question about inheritance

P: n/a
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

Oct 26 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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-lit...heritance.html

TIT
Oct 26 '05 #2

P: n/a
vineoff wrote:
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
Oct 26 '05 #3

P: n/a
Okay, thank you all, searched for that virtual inheritance and found an
answer.

Oct 26 '05 #4

P: n/a
Sorry, meant 'virtual void f() = 0;'.

Oct 26 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.