Class sizes with virtual inheritance in C++

前端 未结 5 2019
[愿得一人]
[愿得一人] 2021-01-02 20:48
#include

using namespace std;

class abc
{
    int a;
};
class xyz : public virtual abc
{
    int b;
};

int main()
{
    abc obj;
    xyz obj1;
            


        
5条回答
  •  没有蜡笔的小新
    2021-01-02 21:33

    With virtual base classes, the position of the base object relative to an instance of the derived object is not always the same, so there is a pointer that tracks that.

提交回复
热议问题