Friend within private nested class

早过忘川 提交于 2019-12-04 21:15:02

You need two friendships here. One to let A know about the private B::D and another to let B::D access private data in A.

Declare (include) class B before declaring class A.

Then in class B, add:

friend class A;

This allows class A to know about the private B::D.

Then in class A, replace:

friend class D;

with:

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