C2011: <Name> can not be accessed

[ERROR]

Description

There is no access to the object specified by the identifier.

Example
  struct A {

  
  private:

  
    int i;

  
  protected:

  
    int j;

  
  public:

  
    int k;

  
    void g();

  
  };

  
  struct B : public A {

  
    void h();

  
  };

  
  void A::g() {

  
    this->i=3;  // ok

  
    this->j=4;  // ok

  
    this->k=5;  // ok

  
  }

  
  void B::h() {

  
    this->i=3;  // error

  
    this->j=4;  // ok

  
    this->k=5;  // ok

  
  }

  
  void f() {

  
    A a;

  
    a.i=3;  // error

  
    a.j=4;  // error

  
    a.k=5;  // ok

  
  }

  
Tips

Change the access specifiers in the class declaration, if you really need access to the object. Or use the friend-mechanism.

See also