title: Prevent subclass outside of a header file
body: <p>I have the following three class defined in a .h file:</p>
  
  <pre><code>class Base
  { // number of pure virtual functions };
  
  class Derived1 : public Base
  { // number of pure virtual functions };
  
  class Derived2 : public Base
  { // number of pure virtual functions };
  </code></pre>
  
  <p>I want users of this header file to only subclass Derived1 or Derived2.  I want to prevent users from subclass'ing Base.  I "could" have used the keyword "final" for class Base, but that would prevent me from subclassing in my header file.  I need to have all the above classes in the header file as a user needs to provide definitions of methods in Base and DerivedX classes.</p>
  
  <p>I am thinking of something like limiting the scope of inheritance to within a header file (similar to a static variable).  Any suggestions or ideas would be greatly appreciated.</p>