<?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[Fehler bei const_iterator]]></title><description><![CDATA[<p>Folgender Code</p>
<pre><code class="language-cpp">#include &lt;vector&gt;
#include &lt;algorithm&gt;

namespace ArraysFunctions
{  
    template&lt;typename T&gt;	int maxPosition(vector&lt;T&gt; const &amp; InArray);
}

template&lt;typename T&gt;
inline int ArraysFunctions::maxPosition(vector&lt;T&gt; const &amp; InArray)
{
    vector&lt;T&gt;::const_iterator it = std::max_element( InArray.begin(), InArray.end() );
    return int(std::distance(InArray.begin(), it));
}
</code></pre>
<p>liefert bei mir den Fehler:</p>
<blockquote>
<p>In file included from QSpectrogramData.h:16,<br />
from QSpectrogramPlot.cpp:3:<br />
..\include/arrayfunctions.h: In function 'int ArraysFunctions::maxPosition(const std::vector&lt;T, std::allocator&lt;_CharT&gt; &gt;&amp;)':<br />
..\include/arrayfunctions.h:133: error: expected ';' before 'it'<br />
..\include/arrayfunctions.h:134: error: 'it' was not declared in this scope<br />
..\include/arrayfunctions.h: In function 'int ArraysFunctions::minPosition(const std::vector&lt;T, std::allocator&lt;_CharT&gt; &gt;&amp;)':<br />
..\include/arrayfunctions.h:140: error: expected ';' before 'it'<br />
..\include/arrayfunctions.h:141: error: 'it' was not declared in this scope</p>
</blockquote>
<p>Nur verstehe ich jetzt überhaupt nicht was an der Zeile mit dem Iterator falsch sein sollte.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/261154/fehler-bei-const_iterator</link><generator>RSS for Node</generator><lastBuildDate>Mon, 25 May 2026 07:53:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/261154.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 14 Feb 2010 14:44:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehler bei const_iterator on Sun, 14 Feb 2010 14:44:09 GMT]]></title><description><![CDATA[<p>Folgender Code</p>
<pre><code class="language-cpp">#include &lt;vector&gt;
#include &lt;algorithm&gt;

namespace ArraysFunctions
{  
    template&lt;typename T&gt;	int maxPosition(vector&lt;T&gt; const &amp; InArray);
}

template&lt;typename T&gt;
inline int ArraysFunctions::maxPosition(vector&lt;T&gt; const &amp; InArray)
{
    vector&lt;T&gt;::const_iterator it = std::max_element( InArray.begin(), InArray.end() );
    return int(std::distance(InArray.begin(), it));
}
</code></pre>
<p>liefert bei mir den Fehler:</p>
<blockquote>
<p>In file included from QSpectrogramData.h:16,<br />
from QSpectrogramPlot.cpp:3:<br />
..\include/arrayfunctions.h: In function 'int ArraysFunctions::maxPosition(const std::vector&lt;T, std::allocator&lt;_CharT&gt; &gt;&amp;)':<br />
..\include/arrayfunctions.h:133: error: expected ';' before 'it'<br />
..\include/arrayfunctions.h:134: error: 'it' was not declared in this scope<br />
..\include/arrayfunctions.h: In function 'int ArraysFunctions::minPosition(const std::vector&lt;T, std::allocator&lt;_CharT&gt; &gt;&amp;)':<br />
..\include/arrayfunctions.h:140: error: expected ';' before 'it'<br />
..\include/arrayfunctions.h:141: error: 'it' was not declared in this scope</p>
</blockquote>
<p>Nur verstehe ich jetzt überhaupt nicht was an der Zeile mit dem Iterator falsch sein sollte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1855465</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1855465</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Sun, 14 Feb 2010 14:44:09 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler bei const_iterator on Sun, 14 Feb 2010 15:11:10 GMT]]></title><description><![CDATA[<p>Versuch mal das:</p>
<pre><code class="language-cpp">typename vector&lt;T&gt;::const_iterator it = std::max_element( InArray.begin(), InArray.end() );
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1855488</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1855488</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sun, 14 Feb 2010 15:11:10 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler bei const_iterator on Sun, 14 Feb 2010 15:13:43 GMT]]></title><description><![CDATA[<p>Ich verstehe zwar nicht warum das die Lösung ist, aber jetzt kompiliert es.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1855490</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1855490</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Sun, 14 Feb 2010 15:13:43 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler bei const_iterator on Sun, 14 Feb 2010 15:23:24 GMT]]></title><description><![CDATA[<p>Darum braucht man typename:</p>
<p><a href="http://pages.cs.wisc.edu/~driscoll/typename.html" rel="nofollow">http://pages.cs.wisc.edu/~driscoll/typename.html</a></p>
<p>Kurzzusammenfassung: Da <code>T</code> erstmal nicht bekannt ist, ist auch nicht bekannt, was <code>vector&lt;T&gt;::const_iterator</code> sein soll, aus der Syntax alleine geht nicht eindeutig hervor, dass es ein Typenbezeichner ist. Es könnte ja zum Beispiel auch eine statische Membervariable sein. Deshalb muss man hier mit dem Schlüsselwort <code>typename</code> kenntlich machen, dass es sich um einen Typenbezeichner handeln soll. Eine genauere Erklärung findet man im verlinkten Text.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1855493</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1855493</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sun, 14 Feb 2010 15:23:24 GMT</pubDate></item></channel></rss>