<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Template-Klasse erweitern]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte die Klasse XSNamedMap des Xerces-C XML-Parsers erweitern. Für die Erweiterung habe ich folgende Klasse zum testen geschrieben:</p>
<p>XSNamedMapExt.h</p>
<pre><code class="language-cpp">#include &lt;iterator&gt;

template&lt;typename T&gt;
class XSNamedMapExt : public XSNamedMap
{
public:
  Iterator begin();
  Iterator end();
};
</code></pre>
<p>und XSNamedMapExt.cpp</p>
<pre><code class="language-cpp">#include &quot;XSNamedMapExt.h&quot;

template&lt;typename T&gt;
Iterator XSNamedMapExt&lt;T&gt;::begin()
{
  return NULL;
}

template&lt;typename T&gt;
Iterator XSNamedMapExt&lt;T&gt;::end()
{
  return NULL;
}
</code></pre>
<p>Versuche ich nun mit</p>
<pre><code>g++ XSNamedMapExt.cpp
</code></pre>
<p>die Klasse zu compilieren kommen mehrere Fehler.</p>
<pre><code>zco@ppc201:~/c/a10$ g++ XSNamedMapExt.cpp
In file included from XSNamedMapExt.cpp:1:
XSNamedMapExt.h:5: error: Fehler beim Parsen before `{' token
XSNamedMapExt.h:10: error: Fehler beim Parsen before `)' token
XSNamedMapExt.cpp:6: error: Syntaxfehler before `&lt;' token
XSNamedMapExt.cpp:6: error: `T' was not declared in this scope
XSNamedMapExt.cpp:6: error: template argument 1 is invalid
XSNamedMapExt.cpp:7: error: ISO C++ forbids declaration of `begin' with no type
XSNamedMapExt.cpp: In function `int begin()':
XSNamedMapExt.cpp:8: Warnung: converting to non-pointer type `int' from NULL
XSNamedMapExt.cpp: At global scope:
XSNamedMapExt.cpp:12: error: Syntaxfehler before `&lt;' token
XSNamedMapExt.cpp:12: error: `T' was not declared in this scope
XSNamedMapExt.cpp:12: error: template argument 1 is invalid
XSNamedMapExt.cpp:13: error: ISO C++ forbids declaration of `end' with no type
XSNamedMapExt.cpp: In function `int end()':
XSNamedMapExt.cpp:14: Warnung: converting to non-pointer type `int' from NULL
</code></pre>
<p>Dass selbst bei so einer minimalen Erweiterung schon solche Fehler kommen hatte ich nicht unbedingt gedacht.</p>
<p>Ich hoffe ihr könnt mir helfen,</p>
<p>Gruß <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/171002/template-klasse-erweitern</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 06:26:43 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/171002.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 21 Jan 2007 18:59:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Template-Klasse erweitern on Sun, 21 Jan 2007 18:59:51 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte die Klasse XSNamedMap des Xerces-C XML-Parsers erweitern. Für die Erweiterung habe ich folgende Klasse zum testen geschrieben:</p>
<p>XSNamedMapExt.h</p>
<pre><code class="language-cpp">#include &lt;iterator&gt;

template&lt;typename T&gt;
class XSNamedMapExt : public XSNamedMap
{
public:
  Iterator begin();
  Iterator end();
};
</code></pre>
<p>und XSNamedMapExt.cpp</p>
<pre><code class="language-cpp">#include &quot;XSNamedMapExt.h&quot;

template&lt;typename T&gt;
Iterator XSNamedMapExt&lt;T&gt;::begin()
{
  return NULL;
}

template&lt;typename T&gt;
Iterator XSNamedMapExt&lt;T&gt;::end()
{
  return NULL;
}
</code></pre>
<p>Versuche ich nun mit</p>
<pre><code>g++ XSNamedMapExt.cpp
</code></pre>
<p>die Klasse zu compilieren kommen mehrere Fehler.</p>
<pre><code>zco@ppc201:~/c/a10$ g++ XSNamedMapExt.cpp
In file included from XSNamedMapExt.cpp:1:
XSNamedMapExt.h:5: error: Fehler beim Parsen before `{' token
XSNamedMapExt.h:10: error: Fehler beim Parsen before `)' token
XSNamedMapExt.cpp:6: error: Syntaxfehler before `&lt;' token
XSNamedMapExt.cpp:6: error: `T' was not declared in this scope
XSNamedMapExt.cpp:6: error: template argument 1 is invalid
XSNamedMapExt.cpp:7: error: ISO C++ forbids declaration of `begin' with no type
XSNamedMapExt.cpp: In function `int begin()':
XSNamedMapExt.cpp:8: Warnung: converting to non-pointer type `int' from NULL
XSNamedMapExt.cpp: At global scope:
XSNamedMapExt.cpp:12: error: Syntaxfehler before `&lt;' token
XSNamedMapExt.cpp:12: error: `T' was not declared in this scope
XSNamedMapExt.cpp:12: error: template argument 1 is invalid
XSNamedMapExt.cpp:13: error: ISO C++ forbids declaration of `end' with no type
XSNamedMapExt.cpp: In function `int end()':
XSNamedMapExt.cpp:14: Warnung: converting to non-pointer type `int' from NULL
</code></pre>
<p>Dass selbst bei so einer minimalen Erweiterung schon solche Fehler kommen hatte ich nicht unbedingt gedacht.</p>
<p>Ich hoffe ihr könnt mir helfen,</p>
<p>Gruß <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1213951</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1213951</guid><dc:creator><![CDATA[zco]]></dc:creator><pubDate>Sun, 21 Jan 2007 18:59:51 GMT</pubDate></item><item><title><![CDATA[Reply to Template-Klasse erweitern on Sun, 21 Jan 2007 22:05:19 GMT]]></title><description><![CDATA[<p>Die erweiterte Klasse ist ein Template. Demnach soltest Du alles - also auch die Implementierung der Methoden - in die H-Datei schreiben. In Deinem Fall am besten inline. Also:</p>
<pre><code class="language-cpp">#include &lt;iterator&gt;
// #include für XSNamedMap fehlt.

template&lt;typename T&gt;
class XSNamedMapExt : public XSNamedMap&lt; T &gt; // steht XSNamedMap nicht im namespace !?
{
public:
  Iterator begin() { return NULL; }
  Iterator end() { return NULL; }
};
</code></pre>
<p>Im Übrigen dürfte Iterator als Typ unbekannt sein; oder?</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1214077</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1214077</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Sun, 21 Jan 2007 22:05:19 GMT</pubDate></item></channel></rss>