Connecting Tech Pros Worldwide Forums | Help | Site Map

A question about inheritance

vineoff
Guest
 
Posts: n/a
#1: Oct 26 '05
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


TIT
Guest
 
Posts: n/a
#2: Oct 26 '05

re: A question about inheritance


vineoff sade:[color=blue]
> 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.[/color]


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
Victor Bazarov
Guest
 
Posts: n/a
#3: Oct 26 '05

re: A question about inheritance


vineoff wrote:[color=blue]
> First, think I'm having an abstract class
>
> class C { public: virtual void f(); };[/color]

No, you're having a brain-o. This is not an abstract class.
[color=blue]
> What is the difference between these two ways:
>
> class D : public C { ... }
> and
> class D : public virtual C { ... }[/color]

For 'D', none.
[color=blue]
> 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?[/color]

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

V
vineoff
Guest
 
Posts: n/a
#4: Oct 26 '05

re: A question about inheritance


Okay, thank you all, searched for that virtual inheritance and found an
answer.

vineoff
Guest
 
Posts: n/a
#5: Oct 26 '05

re: A question about inheritance


Sorry, meant 'virtual void f() = 0;'.

Closed Thread