c++ - 基类是否有可能与其派生类有关联?
问题描述
基类与其派生类有关联关系是否可能/在逻辑上正确?例如:
class First_Child;
class Second_Child;
class Base
{
private:
First_Child** ppFirstChild;
protected:
Second_Child** ppSecondChild;
}
class First_Child : public Base
{
// I want First child to be able to access **ppSecondChild**
}
class Second_Child : public Base
{
// I want Second child to NOT be able to access **ppFirstChild**
}
我在谷歌上没有找到与这个主题相关的东西。请随时提出其他要点[我的目标是能够访问子类评论中提到的那些双指针]。
解决方案
推荐阅读
- python - 找到一个子字符串并打印它直到特定字符
- reactjs - React 历史不能在现场工作,但它可以在本地主机上工作
- pdf - 无法在 Delphi XE3 中添加 Acrobat PDF 控件
- html - 内容正在切割
- ios - iOS 14 UIDevice.current.setValue(xxx, forKey: "orientation") 不起作用
- javascript - 如何在jquery php代码中检查多个复选框
- sql-server - SQL Server 代理定期停止执行 SSIS 作业
- c# - 当操作以对 Challenge(AuthenticationProperties, string[]) 的往返结束时未保存 Cookie
- java - 如何将主体传递给后端 EJB
- vue.js - 解析错误:标识符“商店”已被声明。我在 main.js 上收到此错误,我不知道如何继续