title: Structure definition inside a Class
body: <p>I have been trying to understand this and to find some information about definition of struct type inside a class (for C++). However, I have not find yet any good clarification to my actual doubt.
  In case we have the following definition</p>
  <pre><code>namespace MyOuterNamespace {
    namespace MyInnerNamespace {
      class MyClass {
        struct MyStruct {
          int myVar;
        };
        MyStruct m_MyStruct;
      };
    }
  }
  </code></pre>
  <p>Here in this sample code the m_MyStruct is a private member, so it cannot be access from the outside. However the struct definition is accessible and we can declare a struct variable of this type in any place with</p>
  <pre><code>MyOuterNamespace::MyInnterNamespace::MyClass::MyStruct outsideStruct;
  </code></pre>
  <p>What is the principal to make this possible. If the structure is defined as a type in the private section of the class, why is possible to use it from outside? Is this working only as &quot;namespace&quot; for the structure definition. It is not actually hidden as the struct variable.</p>
  <p>I have found out several articles but maybe this answer from a similar thread is actually answering and giving the principal of how this is understood by the language: <a href="https://stackoverflow.com/a/1816206/10900581">Nested structures</a></p>
  <p>Can anybody confirm this or provide a better explanation?</p>
  <p>[EDIT] You can do this for public definitions but for private you face the expected visibility error.</p>
  <p>Thanks!</p>