473,326 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Virtual Inheritance

Hi, everyone,

I was stumped at an interview several months ago when questioned about the
use of the keyword "virtual" when inheriting a base class into a derived
class. I was told by the interviewer that this was useful in some cases of
multiple inheritance. Now I'm wondering what those cases are, and how they
occur, and exactly what this usage does to rectify the problem.

Can anyone help me understand this or recommend a resource that can?

Thanks,
Scott

--
Remove ".nospam" from the user ID in my e-mail to reply via e-mail.
Jul 22 '05 #1
4 1331
Scott Brady Drummonds wrote:
Hi, everyone,

I was stumped at an interview several months ago when questioned about the
use of the keyword "virtual" when inheriting a base class into a derived
class. I was told by the interviewer that this was useful in some cases of
multiple inheritance. Now I'm wondering what those cases are, and how they
occur, and exactly what this usage does to rectify the problem.

Can anyone help me understand this or recommend a resource that can?


See:

http://www.parashift.com/c++-faq-lit....html#faq-25.8

[In fact, reading the whole `chapter' -- and for that matter the rest of
the FAQ -- would likely be fruitful.]

HTH,
--ag
--
Artie Gold -- Austin, Texas
Jul 22 '05 #2

"Artie Gold" <ar*******@austin.rr.com> wrote in message
news:bu************@ID-219787.news.uni-berlin.de...
See:

http://www.parashift.com/c++-faq-lit....html#faq-25.8


Ugh... Many apologies for asking a FAQ question. I have the printed FAQ
(C++ FAQs...) and could not find this question there. I'll be sure and
check online next time, too.

Thanks for the pointer!

Scott
Jul 22 '05 #3

"Artie Gold" <ar*******@austin.rr.com> wrote in message
news:bu************@ID-219787.news.uni-berlin.de...
Scott Brady Drummonds wrote:
Hi, everyone,

I was stumped at an interview several months ago when questioned about the use of the keyword "virtual" when inheriting a base class into a derived
class. I was told by the interviewer that this was useful in some cases of multiple inheritance. Now I'm wondering what those cases are, and how they occur, and exactly what this usage does to rectify the problem.

Can anyone help me understand this or recommend a resource that can?


See:

http://www.parashift.com/c++-faq-lit....html#faq-25.8

[In fact, reading the whole `chapter' -- and for that matter the rest of
the FAQ -- would likely be fruitful.]

HTH,
--ag
--
Artie Gold -- Austin, Texas


You sure know how to kill a good conversation.
Jul 22 '05 #4
Scott Brady Drummonds wrote:
Artie Gold wrote:
See:

http://www.parashift.com/c++-faq-lit....html#faq-25.8


Ugh... Many apologies for asking a FAQ question.
I have the printed FAQ (C++ FAQs...)
and could not find this question there.
I'll be sure and check online next time, too.


It doesn't hurt to ask.
I just wish more C++ Gurus would read the C++ FAQ
so that they could cite relevant questions (answers)
the way that Artie Gold did above.

Way to go Artie!

Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: nenad | last post by:
Wouldn't it be nice if we could do something like this: class Funky{ public: auto virtual void doStuff(){ // dostuff } };
4
by: JKop | last post by:
I'm starting to think that whenever you derive one class from another, that you should use virtual inheritance *all* the time, unless you have an explicit reason not to. I'm even thinking that...
14
by: Bruno van Dooren | last post by:
Hi all, i am having a problems with inheritance. consider the following: class A { public: A(int i){;} };
3
by: Imre | last post by:
Hi! I've got some questions regarding heavy use of virtual inheritance. First, let's see a theoretical situation, where I might feel tempted to use a lot of virtual inheritance. Let's...
3
by: kikazaru | last post by:
Is it possible to return covariant types for virtual methods inherited from a base class using virtual inheritance? I've constructed an example below, which has the following structure: Shape...
12
by: mijobee | last post by:
I'm very new to c++ and just writing some code to learn. I've run into a problem, with a javaish design, and want to know if there is any possible solution without modifying the design. I've read...
5
by: toton | last post by:
Hi, I want a few of my class to overload from a base class, where the base class contains common functionality. This is to avoid repetition of code, and may be reducing amount of code in binary,...
23
by: Dave Rahardja | last post by:
Since C++ is missing the "interface" concept present in Java, I've been using the following pattern to simulate its behavior: class Interface0 { public: virtual void fn0() = 0; };
12
by: Massimo | last post by:
Hi to all, I'm facing a problem in a particularly complex inheritance hierarchy, and I'd like to know what the standard says about it and if my compiler is correct in what it does. I have two...
0
by: =?Utf-8?B?Zmplcm9uaW1v?= | last post by:
Hi all, As I mentioned in a previous thread (see 'Dbghelp, symbols and templates' in microsoft.public.windbg), we created a powerful symbol engine using dbghelp to dump the contents of the stack...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.