Virtual inheritance doesn't break static composition?

前端 未结 3 1860
执笔经年
执笔经年 2020-12-15 13:53

I was working the last 5 years with the assumption that virtual inheritance breaks static composition.

But now I discovered, that static composition is still maintai

3条回答
  •  没有蜡笔的小新
    2020-12-15 14:42

    Objects of classes that use virtual inheritance have a fixed memory layout that is determined in compilation time. Accessing the virtual base however requires a level of indirection since you cannot tell where it is relative to the derived pointer.

    See Wikipedia

提交回复
热议问题