title: C++ namespaces advice
body: <p>I'm just teaching myself C++ namespaces (coming from a C# background) and I'm really starting to think that even with all the things that C++ does better than most other languages, nested namespaces isn't one of them!</p>
  
  <p>Am I right in thinking that in order to declare some nested namespaces I have to do the following:  </p>
  
  <pre><code>namespace tier1
  {
      namespace tier2
      {
          namespace tier3
          {
              /* then start your normal code nesting */
          }
      }
  }
  </code></pre>
  
  <p>As opposed to:  </p>
  
  <pre><code>namespace tier1::tier2::tier3
  {
  }
  </code></pre>
  
  <p>à la C#?</p>
  
  <p>This becomes even more demented when I need to forward declare:</p>
  
  <pre><code>namespace tier1
  {
      namespace tier2
      {
          namespace forward_declared_namespace
          {
              myType myVar; // forward declare
          }
          namespace tier3
          {
              /* then start your normal code nesting */
              class myClass
              {
                  forward_declared_namespace::myType myMember;
              }
          }
      }
  }
  </code></pre>
  
  <p>Bearing in mind that a typical system that I develop consists of:</p>
  
  <pre><code>MyCompany::MySolution::MyProject::System::[PossibleSections]::Type
  </code></pre>
  
  <p>Is this why you don't tend to see much use of namespaces in C++ examples? Or usually only single (not nested) namespaces?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>For anyone interested, <a href="http://www.adamjamesnaylor.com/2012/10/23/NestedNamespacesInC.aspx" rel="noreferrer">this is how I ended up</a> tackling this issue.</p>