gpt4 book ai didi

C++ friend 继承?

转载 作者:IT老高 更新时间:2023-10-28 12:41:00 26 4
gpt4 key购买 nike

子类是否继承主类的友元关联(主类自己的以及与主类有友元的其他类)?

或者换句话说,继承如何应用于friend关键字?

展开:如果没有,有什么方法可以继承友元?

我已按照 Jon 的建议发布设计问题:
C++ class design questions

最佳答案

友元不会在 C++ 中继承。

标准规定(ISO/IEC 14882:2003,第 11.4.8 节):

Friendship is neither inherited nor transitive.

关于C++ friend 继承?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7371087/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com