title: Is anyone familiar with the "implementation/internal header" (*.ih)?
body: <p>In the half-year C++ course by F.B. Brokken (author of The C++ Annotations), we have been taught the use of so-called implementation headers. I knew that this is a convention by Frank, but I have literally NEVER seen it anywhere else. I'll therefore explain the concept and I'm very curious about what other people make of this.</p>
  
  <p>The idea is that you just put all <code>#include</code> directives that are needed by the implementations of your class-members' implementations (assuming you're not writing in-class definitions) in one file, the .ih implementation header, and <code>#include</code> this file in every source file instead. The alternatives are<br>
  1) <code>#include</code> everything in the class-header or<br>
  2) <code>#include</code> all headers seperately in every source-file.  </p>
  
  <p>The downsides to both alternatives are obvious:<br>
  1a) You have to recompile all sources <code>#include</code>'ing this header after adding anything that requires some additional <code>#include</code>'s.<br>
  1b) Your header file, that is supposed to be a clear interface of your class, gets polluted with a great bunch of <code>#include</code> directives of which the user has no idea what they are used for, nor does he care.
  2a) You have to <code>#include</code> the same headers again and again in each source file.<br>
  2b) Your implementation is polluted by all these <code>#include</code>'s, making it look just a little messy.</p>
  
  <p>Just to be clear:</p>
  
  <pre><code>/* someclass.h(pp) */
  
  #ifndef SOME_CLASS_H
  #define SOME_CLASS_H
  
  class SomeClass
  {
      //some private data members
      public:
          SomeClass();
          void sayHi() const;
          // some more member functions
      private:
          // some private member functions
  };
  
  #endif
  
  /* someclass.ih */
  
  #include "someclass.h"
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  using namespace std; 
  
  // namespace is now only used in my implementations, other people
  // including my headers won't accidentally import the entire std namespace.
  
  /* sayhi.cc */
  
  #include "someclass.ih"
  
  void SomeClass::sayHi() const
  {
       cout &lt;&lt; "sayHi() says hi!\n";
  }
  </code></pre>
  
  <p>Now, again, the question is: has anyone ever heard of such a convention? Did I convince anyone to start using it? I personally find it a very useful (even obvious) convention and I'm a little surprised that I haven't seen it anywhere else.</p>