title: Best practices for use of C++ header files
body: <p>I have the following doubts on header files usage.</p>
  
  <p><strong>1 - Include guards placing after comments</strong></p>
  
  <pre><code>/* Copyright Note and licence information (multiple lines) */
  #ifndef FOO_H
  #define FOO_H
  // Header file contents
  #endif
  </code></pre>
  
  <p>Herb Sutter says in his "C++ coding standards" book that code like the above is problematic. He is saying the "#ifndef" statements should appear in the first line of the header file. I haven't felt this as convincing. Is this followed by you guys/gals in header files?</p>
  
  <p><strong>2 - Using namespaces in header files</strong></p>
  
  <pre><code>#ifndef FOO_H
  #define FOO_H
  namespace FooNameSpace{
      // Header file contents
  }
  #endif
  </code></pre>
  
  <p>Is the above code using correct practice? I mean, do you use namespaces in header files? I know why importing a namespace in header file is pointless but what about a declaration like the above?</p>
  
  <p>If the above one is the correct method, how do you do "<em>forward declaration</em>" of a class which is in another namespace? Is it like</p>
  
  <pre><code>#ifndef FOO_H
  #define FOO_H
  namespace AnotherNameSpace{
      class AnotherFoo; // forward declaration
  }
  
  namespace FooNameSpace{
      // Use AnotherFoo here
  }
  #endif
  </code></pre>
  
  <p>The "<em>forward declaration</em>" is the only method to avoid "<em>cyclic dependency</em>", correct?</p>