Nested Class member function can't access function of enclosing class. Why?

后端 未结 4 1678
不知归路
不知归路 2020-12-09 17:02

Please see the example code below:

class A
{
private:
    class B
    {
    public:
        foobar();
    };
public:
    foo();
    bar();
};
4条回答
  •  天涯浪人
    2020-12-09 17:26

    If you want to reuse functionality from A then you should inherit from A not nest B inside it.

提交回复
热议问题