title: How to propagate friend for derived classes
body: <p>I want to have a class hierarchy and be able to create objects from it only inside a Factory.</p>
  
  <p>Example:</p>
  
  <pre><code>class Base
  {
      protected:
          Base(){};
          virtual void Init(){};
  
      friend class Factory;
  };
  
  class SomeClass : public Base
  {
      public://I want protected here! Now it's possible to call new SomeClass from anywhere!
          SomeClass(){};
          void Init(){};
  };
  
  class Factory
  {
      public:
          template&lt;class T&gt;
          T* Get()
          {
              T* obj = new T();
              obj-&gt;Init();
  
              return obj;
          }
  };
  
  int main()
  {
      Factory factory;
      SomeClass *obj = factory.Get&lt;SomeClass&gt;();
  }
  </code></pre>
  
  <p>My problem is that I want to be able to make objects only from Factory, but I don't want to declare <code>friend class Factory</code> in every class derived from Base. </p>
  
  <p>Is there any way to propagate friend in derived classes? Is there any other way to achieve this behavior? </p>