<?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[Iterator in abgeleiteter Template Klasse benutzen]]></title><description><![CDATA[<p>Ich habe eine Klasse MyMap von std::map angeleitet. Die beiden template arguments habe ich beibehalten.</p>
<pre><code class="language-cpp">#include &lt;map&gt;
using namespace std;

template&lt;typename T, typename T0&gt;
class MyMap : public std::map&lt;T,T0&gt;
{
public:
    void foo();

};

template&lt;typename T, typename T0&gt;
void MyMap&lt;T,T0&gt;::foo()
{

    for(iterator it(begin()); it!=end(); ++it)   //&lt;-- compile time error
        it-&gt;bla();

    //klappt auch nicht:
    //for(MyMap&lt;T,T0&gt;::iterator it(begin()); it!=end(); ++it)
    //    it-&gt;bla();
}
</code></pre>
<p>Es gibt Probleme mit dem statement: iterator it(begin())</p>
<p>Any help?</p>
<p>thx in advance</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/137182/iterator-in-abgeleiteter-template-klasse-benutzen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 17:04:16 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/137182.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 15 Feb 2006 18:35:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Iterator in abgeleiteter Template Klasse benutzen on Wed, 15 Feb 2006 18:35:15 GMT]]></title><description><![CDATA[<p>Ich habe eine Klasse MyMap von std::map angeleitet. Die beiden template arguments habe ich beibehalten.</p>
<pre><code class="language-cpp">#include &lt;map&gt;
using namespace std;

template&lt;typename T, typename T0&gt;
class MyMap : public std::map&lt;T,T0&gt;
{
public:
    void foo();

};

template&lt;typename T, typename T0&gt;
void MyMap&lt;T,T0&gt;::foo()
{

    for(iterator it(begin()); it!=end(); ++it)   //&lt;-- compile time error
        it-&gt;bla();

    //klappt auch nicht:
    //for(MyMap&lt;T,T0&gt;::iterator it(begin()); it!=end(); ++it)
    //    it-&gt;bla();
}
</code></pre>
<p>Es gibt Probleme mit dem statement: iterator it(begin())</p>
<p>Any help?</p>
<p>thx in advance</p>
]]></description><link>https://www.c-plusplus.net/forum/post/995174</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/995174</guid><dc:creator><![CDATA[Raptor]]></dc:creator><pubDate>Wed, 15 Feb 2006 18:35:15 GMT</pubDate></item><item><title><![CDATA[Reply to Iterator in abgeleiteter Template Klasse benutzen on Wed, 15 Feb 2006 19:30:47 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">for(typename MyMap&lt;T,T0&gt;::iterator it(begin()); it!=end(); ++it)
</code></pre>
<p>So funktionierts, siehe dazu: <a href="http://www.slac.stanford.edu/BFROOT/www/Computing/Programming/GCCWarnings.html" rel="nofollow">http://www.slac.stanford.edu/BFROOT/www/Computing/Programming/GCCWarnings.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/995225</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/995225</guid><dc:creator><![CDATA[KPC]]></dc:creator><pubDate>Wed, 15 Feb 2006 19:30:47 GMT</pubDate></item><item><title><![CDATA[Reply to Iterator in abgeleiteter Template Klasse benutzen on Wed, 15 Feb 2006 19:39:57 GMT]]></title><description><![CDATA[<p>Na, das is ja mal ein Ding</p>
<blockquote>
<p>this is because the C++ standard rule is that every identifier that involves a template is interpreted as a value unless it is explicitly qualified as a typename. Thus, when you write;</p>
<p>vector&lt;T&gt;::const_iterator i;</p>
<p>const_iterator may be interpreted as a static member of the class vector&lt;T&gt;. To make it clear that it is the type that declares the value i, one needs to write;</p>
<p>typename vector&lt;T&gt;::const_iterator i;</p>
</blockquote>
<p>Da waere ich auch nicht von alleine drauf gekommen..<br />
Vielen Dank!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/995232</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/995232</guid><dc:creator><![CDATA[Raptor]]></dc:creator><pubDate>Wed, 15 Feb 2006 19:39:57 GMT</pubDate></item><item><title><![CDATA[Reply to Iterator in abgeleiteter Template Klasse benutzen on Wed, 15 Feb 2006 19:50:03 GMT]]></title><description><![CDATA[<p>Raptor schrieb:</p>
<blockquote>
<p>Na, das is ja mal ein Ding</p>
<blockquote>
<p>this is because the C++ standard rule is that every identifier that involves a template is interpreted as a value unless it is explicitly qualified as a typename. Thus, when you write;</p>
<p>vector&lt;T&gt;::const_iterator i;</p>
<p>const_iterator may be interpreted as a static member of the class vector&lt;T&gt;. To make it clear that it is the type that declares the value i, one needs to write;</p>
<p>typename vector&lt;T&gt;::const_iterator i;</p>
</blockquote>
<p>Da waere ich auch nicht von alleine drauf gekommen..<br />
Vielen Dank!</p>
</blockquote>
<p>Wenn du dich jetzt eventuell noch fragst, warum? Dann ist dieser Link imho ebenfalls hilfreich: <a href="http://www.gotw.ca/gotw/035.htm" rel="nofollow">http://www.gotw.ca/gotw/035.htm</a>.</p>
<p>Gruß Caipi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/995240</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/995240</guid><dc:creator><![CDATA[Caipi]]></dc:creator><pubDate>Wed, 15 Feb 2006 19:50:03 GMT</pubDate></item></channel></rss>