invalid use of non-static data member

前端 未结 4 1981
暖寄归人
暖寄归人 2021-02-01 14:06

For a code like this:

class foo {
  protected:
    int a;
  public:
    class bar {
      public:
        int getA() {return a;}   // ERROR
    };
    foo()
             


        
4条回答
  •  粉色の甜心
    2021-02-01 14:07

    You try to access private member of one class from another. The fact that bar-class is declared within foo-class means that bar in visible only inside foo class, but that is still other class.

    And what is p->param?

    Actually, it isn't clear what do you want to do

提交回复
热议问题