首页 > 解决方案 > 基类是否有可能与其派生类有关联?

问题描述

基类与其派生类有关联关系是否可能/在逻辑上正确?例如:

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**
}

我在谷歌上没有找到与这个主题相关的东西。请随时提出其他要点[我的目标是能够访问子类评论中提到的那些双指针]。

标签: c++class

解决方案


推荐阅读