title: How to set base class members before derived class constructor is called?
body: <p>There is a base class for components of my application which provides some members and the functions <code>Init()</code> and <code>Update()</code> which must be overwritten.</p>
  
  <pre><code>class Component
  {
  public:
      void Set(type* Member1, type* Member2, type* Member3)
      {
          this-&gt;Member1 = Member1;
          this-&gt;Member2 = Member2;
          this-&gt;Member3 = Member3;
      }
      virtual void Init() = 0;
      virtual void Update() = 0;
      virtual ~Component() {}
  protected:
      type* Member1;
      type* Member2;
      type* Member3;
  };
  </code></pre>
  
  <p>For handeling the components, there is a manager. It first sets the members of a component and then calls <code>Init()</code> on it. Later on it can be used to update all assigned components but that isn't related to this question.</p>
  
  <pre><code>class Manager
  {
  public:
      void Add(string Name, Component* Component)
      {
          list[Name] = Component;
      }
      void Init(type* Member1, type* Member2, type* Member3)
      {
          for (auto i = list.begin(); i != list.end(); i++)
          {
              i-&gt;second-&gt;Set(Member1, Member2, Member3);
              i-&gt;second-&gt;Init();
          }
      }
      void Update()
      {
          for (auto i = list.begin(); i != list.end(); i++)
              i-&gt;second-&gt;Update();
      }
  private:
      unordered_map&lt;string, Component*&gt; list;
  };
  </code></pre>
  
  <p>I am not really happy with my implementation since I would like components to use their constructor for initialization instead overwriting the <code>Init()</code> function. But at construction time the base class member aren't available yet.</p>
  
  <p>I know that I could pass the members through the derived class constructor, but I do not want specific components to care about their base class' members. That would look like the following but anyway I do not want that.</p>
  
  <pre><code>class Component
  {
  public:
      Component(type* Member1, type* Member2, type* Member3)
      {
          this-&gt;Member1 = Member1;
          this-&gt;Member2 = Member2;
          this-&gt;Member3 = Member3;
      }
      virtual void Update() = 0;
      virtual ~Component();
  protected:
      type* Member1;
      type* Member2;
      type* Member3;
  };
  
  class Specific : public Component
  {
  public:
      Specific(type* Member1, type* Member2, type* Member3) : Component(Member1, Member2, Member3)
      {
  
      }
      void Update()
      {
  
      }
  };
  </code></pre>
  
  <p>So how can I insure that the base class members are initialized before calling the constructor of the derived class?</p>