title: Invalid use of non-static data member when nested class function is used, but OK when the function is not-nested?
body: <p>I am trying to manipulate 'registerTable' with 'ChargerClass::SystemStruct::initNested()', with a function from an object passed in during initialisation 'interface'.</p>
  
  <p>The reason I want to nest is to enable the use of dot notation to use the Class members; there will be a lot of functions in this class and dot notation will make clear what part of the class is being utilised.</p>
  
  <p>'chargerHAL_r hal' must be passed in as it is an abstraction layer object to allow for multiple communication protocols to be used with the ChargerClass.</p>
  
  <p>If initNested() is within 'SystemStruct', I get compiler errors:</p>
  
  <ul>
  <li>invalid use of non-static data member 'ChargerClass::interface'</li>
  <li>invalid use of non-static data member 'ChargerClass::registerTable'</li>
  </ul>
  
  <p>However, if initNOTNested() is in the parent class ChargerClass and not nested in SystemStruct. it compiles just fine.</p>
  
  <p>I have included comments in the code snippet for both initNested() and initNOTNested();</p>
  
  <p>I am using C++11, and since this version, nested-class access to enclosing-class members is valid, no?</p>
  
  <p>What am I missing?</p>
  
  <pre><code>struct chargerHAL_r {
      static void readAllRegisters(uint8_t *regTable);
  };
  
  
  class ChargerClass {
  public:
      ChargerClass(chargerConfig_r config, chargerHAL_r hal) {
          interface = hal;
      }
  
  
      struct system_r {
          bool initNested(); /* Compiler throws error */
      };
  
      bool initNotNested(); /* Compiles OK */
  
  
  private:
      uint8_t registerTable[20];
      chargerHAL_r interface;
  };
  
  
  /* Compiler throws error */
  bool ChargerClass::system_r::initNested() {
      interface.readAllRegisters(registerTable);
  }
  
  /* Compiles OK */
  bool ChargerClass::initNotNested() {
      interface.readAllRegisters(registerTable);
  }
  </code></pre>