Multiple inheritance without virtual functions in c++

旧时模样 提交于 2019-12-03 11:39:23

s->kid1::val does not mean "val from the kid1 subobject". It's just a name qualified by the type (not the subobject) that contains it.

I don't know why country1::kid1 is even accepted at all, but apparently it's a typedef for ::kid1. Two data members in world both have the qualified name ::kid1::val.

What you want is:

world* w = new world;
country1* const c1 = world;
c1->kid1::val = 1;

It is. The error is due to a bug in your compiler.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!