小编Jas*_*son的帖子

虚拟继承中的虚拟基本偏移量

代码如下(使用G ++编译的C++ 11代码 - 在Ubuntu 16.04上为5.4):

#include <iostream>

using namespace std;



class Base
{
    public:
        virtual void show()
        {
            cout << "Base" << endl;
        }

        virtual void func()
        {
            cout << "func in Base" << endl;
        }

    protected:
        int base = 15;
};

class A: public virtual Base
{
    public:
        void show() override
        {
            cout << this << endl;
            cout << 'A' << endl;
        }

        void func() override
        {
            cout << this << endl;
            cout << "func in A" << …
Run Code Online (Sandbox Code Playgroud)

c++ virtual-inheritance c++11

6
推荐指数
1
解决办法
522
查看次数

标签 统计

c++ ×1

c++11 ×1

virtual-inheritance ×1