Virtual Inheritance Confusion

Posted by alan on Stack Overflow See other posts from Stack Overflow or by alan
Published on 2011-11-16T08:08:27Z Indexed on 2011/11/16 9:50 UTC
Read the original article Hit count: 431

I'm reading about inheritance and I have a major issue that I haven't been able to solve for hours:

Given a class Bar is a class with virtual functions,

class Bar
{
    virtual void Cook();
}

What is the different between:

class Foo : public Bar
{
    virtual void Cook();
}

and

class Foo : public virtual Bar
{
    virtual void Cook();
}

? Hours of Googling and reading came up with lots of information about its uses, but none actually tell me what the difference between the two are, and just confuse me more.

Thanks!

© Stack Overflow or respective owner

Related posts about c++

Related posts about inheritance