title: Can a specialized template method bypass the default one that would not compile due to the creation of an abstract object?
body: <p>It might be a weird question, but it could be quite handy in my use case.</p>
  <p>I have the generic class:</p>
  <pre><code>template &lt;typename CGtObj&gt;
  class CGtObjectsMap
  {
      virtual CGtObj* newGtObject(GtId idXML, const CSAXElement *) const { return new CGtObj(idXML); } //!&lt; can be overwritten by MyAbstractClass ;)
      virtual void loadFromXml(CSAXElement const* element);
  };
  </code></pre>
  <p>with a &quot;quite complex&quot; <code>loadFromXml(CSAXElement const* element)</code> that has at one point:</p>
  <pre><code>template &lt;typename CGtObj&gt;
  void CGtObjectsMap&lt;CGtObj&gt;::loadFromXml(const CSAXElement *element)
  {
      ...
      objPtr = newGtObject(idXML, element);//new CGtObj(idXML);
      ...
  }
  </code></pre>
  <p>A certain class I need to use in that <code>CGtObjectsMap</code> is abstract. That is why I've created the virtual method <code>newGtObject</code>, hoping I could avoid duplicating the whole code of <code>loadFromXml()</code> in a specialization of that class.</p>
  <p>But it doesn't compile, and I'm having an error on the template standard definition of <code>newGtObject()</code>:</p>
  <blockquote>
  <p>error: invalid new-expression of abstract class type ‘MyAbstractClass’</p>
  </blockquote>
  <p>coming from:</p>
  <pre><code>virtual CGtObj* newGtObject(GtId idXML, const CSAXElement *) const { return new CGtObj(idXML); } //!&lt; can be overwritten by MyAbstractClass ;)
  </code></pre>
  <p>although I've specialized it:</p>
  <pre><code>template&lt;&gt;
  MyAbstractClass *CGtObjectsMap&lt;MyAbstractClass&gt;::newGtObject(GtId idXML, const CSAXElement *element) const
  {
      MyAbstractClassType type = static_cast&lt;MyAbstractClassType&gt;(element-&gt;childValueByName(XML_TYPE).toInt());
      return MyAbstractClass::createAction(type, idXML);
  }
  </code></pre>
  <p>Is there a way to avoid that compilation issue?</p>
  <p>(The specialization is in another file)</p>