咨詢個(gè)菱形繼承的問題基類Person有個(gè)屬性Color,類Worker和Farmer都繼承Person,類MigrantWorker繼承Worker和Farmer,main中新建MigrantWorker,調(diào)用Worker和Farmer的屬性和函數(shù)都正常,但調(diào)用Person的屬性就提示:reference to ‘Color’ is ambiguousColor是模棱兩可的,應(yīng)該是Color在Worker和Farmer中都有,計(jì)算機(jī)不曉得該調(diào)用哪個(gè)請(qǐng)問應(yīng)該怎么調(diào)用Colorps:初始化沒問題,就是無(wú)法調(diào)用
- 3 回答
- 0 關(guān)注
- 1713 瀏覽
添加回答
舉報(bào)
0/150
提交
取消