In C++, what is a virtual base class?

后端 未结 11 2147
一个人的身影
一个人的身影 2020-11-22 00:55

I want to know what a \"virtual base class\" is and what it means.

Let me show an example:

class Foo
{
public:
    void DoSomething() { /* .         


        
11条回答
  •  情深已故
    2020-11-22 01:17

    You're being a little confusing. I dont' know if you're mixing up some concepts.

    You don't have a virtual base class in your OP. You just have a base class.

    You did virtual inheritance. This is usually used in multiple inheritance so that multiple derived classes use the members of the base class without reproducing them.

    A base class with a pure virtual function is not be instantiated. this requires the syntax that Paul gets at. It is typically used so that derived classes must define those functions.

    I don't want to explain any more about this because I don't totally get what you're asking.

提交回复
热议问题