C++ Access private member of nested class

前端 未结 3 1628
再見小時候
再見小時候 2021-01-19 10:21

The title might be a bit misleading. I have the following problem: I have a tree consisting of leaves and internal nodes. The user should be able to store any information in

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-19 11:12

    You may do

    class Outer {
       private: // maybe protected:
       class Inner {
          public:
          ....
       };
    };
    

    or

    class Outer {
       public:
       class Inner {
          friend class Outer;
          private:
          ....
       };
    };
    

提交回复
热议问题