title: C++ template parent class constructor on child class
body: <p>I have this</p>
  
  <pre><code>template&lt;class PayloadType&gt;
      class Event {
      protected:
          PayloadType payload;
      public:
          Event(PayloadType payload);
      };
  </code></pre>
  
  <p>This is the definition:</p>
  
  <pre><code>template&lt;class PayloadType&gt;
  Event&lt;PayloadType&gt;::Event(PayloadType payload) {
      this-&gt;payload = payload;
  }
  </code></pre>
  
  <p>And this:</p>
  
  <pre><code>class SimplePayload {
  protected:
      int number;
  public:
      SimplePayload(int number) : number(number) { }
      int getNumber() { return number; };
  };
  
  template&lt;class PayloadType&gt;
  class SimpleEvent : public Event&lt;PayloadType&gt; {
  protected:
      PayloadType payload;
  public:
      SimpleEvent(PayloadType payload) : Event&lt;PayloadType&gt;(payload) { }
  };
  </code></pre>
  
  <p>Trying to use it:</p>
  
  <pre><code>SimplePayload simplePayload;
  SimpleEvent&lt;SimplePayload&gt; *simpleEvent = dynamic_cast&lt;SimpleEvent&lt;SimplePayload&gt;*&gt;(new Event&lt;SimplePayload&gt;(simplePayload));
  </code></pre>
  
  <p>And I'm getting this error:</p>
  
  <pre><code>error: member initializer 'Event' does not name a non-static data member or base class
  </code></pre>
  
  <p>How can I properly construct the object?</p>