<?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[STL class vector::iterator - wie muss das aussehen?]]></title><description><![CDATA[<p>Also ich habe eine Klasse, die sieht ungefähr so aus:</p>
<pre><code class="language-cpp">template &lt;class T&gt; class cTree
{

    private:
    T   data;
    vector&lt;cTree*&gt; child;

    public:
    int id;

};
</code></pre>
<p>jetzt will ich einen Baum erstellen in dem ich an ein Element mit der ID xyz ein neues anhängen kann.</p>
<p>die Funktion müsste ja jetzt prüfen, ob denn das jeweils bearbeitende Element die gleiche ID hat wie das gewünschte Parent-Element. Ist dies der Fall wird nen push_back() gemacht und das neue Element einfach dran gehängt.</p>
<p>Ist dem nicht so, muss ich für jedes child-Element meine add-Funktion aufrufen.<br />
Mein Problem ist nun, dass er einen Iterator in der Form</p>
<pre><code class="language-cpp">vector&lt;cTree* &gt;::iterator it;
</code></pre>
<p>nicht annimmt. Der Compiler meldet &quot;expected ; before 'it'&quot;</p>
<p>Kann mir jemand erklären, wie mein Iterator auszusehen hat???</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/122805/stl-class-vector-iterator-wie-muss-das-aussehen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 08:56:19 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/122805.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 10 Oct 2005 10:51:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to STL class vector::iterator - wie muss das aussehen? on Mon, 10 Oct 2005 10:52:38 GMT]]></title><description><![CDATA[<p>Also ich habe eine Klasse, die sieht ungefähr so aus:</p>
<pre><code class="language-cpp">template &lt;class T&gt; class cTree
{

    private:
    T   data;
    vector&lt;cTree*&gt; child;

    public:
    int id;

};
</code></pre>
<p>jetzt will ich einen Baum erstellen in dem ich an ein Element mit der ID xyz ein neues anhängen kann.</p>
<p>die Funktion müsste ja jetzt prüfen, ob denn das jeweils bearbeitende Element die gleiche ID hat wie das gewünschte Parent-Element. Ist dies der Fall wird nen push_back() gemacht und das neue Element einfach dran gehängt.</p>
<p>Ist dem nicht so, muss ich für jedes child-Element meine add-Funktion aufrufen.<br />
Mein Problem ist nun, dass er einen Iterator in der Form</p>
<pre><code class="language-cpp">vector&lt;cTree* &gt;::iterator it;
</code></pre>
<p>nicht annimmt. Der Compiler meldet &quot;expected ; before 'it'&quot;</p>
<p>Kann mir jemand erklären, wie mein Iterator auszusehen hat???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/888698</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/888698</guid><dc:creator><![CDATA[DocJunioR]]></dc:creator><pubDate>Mon, 10 Oct 2005 10:52:38 GMT</pubDate></item><item><title><![CDATA[Reply to STL class vector::iterator - wie muss das aussehen? on Mon, 10 Oct 2005 10:54:27 GMT]]></title><description><![CDATA[<p>setz mal ein typename davor :</p>
<pre><code>typename vector&lt;cTree&lt;T&gt;* &gt;::iterator it;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/888702</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/888702</guid><dc:creator><![CDATA[phlox81]]></dc:creator><pubDate>Mon, 10 Oct 2005 10:54:27 GMT</pubDate></item><item><title><![CDATA[Reply to STL class vector::iterator - wie muss das aussehen? on Mon, 10 Oct 2005 10:57:18 GMT]]></title><description><![CDATA[<p>phlox81 schrieb:</p>
<blockquote>
<p>setz mal ein typename davor :</p>
<pre><code>typename vector&lt;cTree&lt;T&gt;* &gt;::iterator it;
</code></pre>
</blockquote>
<p>Nicht raten!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/888705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/888705</guid><dc:creator><![CDATA[wissen]]></dc:creator><pubDate>Mon, 10 Oct 2005 10:57:18 GMT</pubDate></item><item><title><![CDATA[Reply to STL class vector::iterator - wie muss das aussehen? on Mon, 10 Oct 2005 11:03:44 GMT]]></title><description><![CDATA[<p>Das hat aber schon etwas gebracht. Ich bekomm nix fehler mehr.<br />
thx</p>
]]></description><link>https://www.c-plusplus.net/forum/post/888709</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/888709</guid><dc:creator><![CDATA[DocJunioR]]></dc:creator><pubDate>Mon, 10 Oct 2005 11:03:44 GMT</pubDate></item><item><title><![CDATA[Reply to STL class vector::iterator - wie muss das aussehen? on Mon, 10 Oct 2005 11:07:05 GMT]]></title><description><![CDATA[<p>DocJunior schrieb:</p>
<blockquote>
<pre><code>vector&lt;cTree* &gt;::iterator it;
</code></pre>
</blockquote>
<p>Das dürfte nicht funktionieren, da cTree selber ja auch eine Template-Parameter erwartet. Du brauchste quasi &quot;vector&lt;cTree&lt;T&gt;*&gt;&quot;.</p>
<p>Solange der vector nicht selbst ein Template-Parameter ist brauchste da auch kein typename.</p>
<p>Edit: Sehe gerade dein Post.<br />
Geht das wirklich?</p>
<pre><code>vector&lt;cTree*&gt; child;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/888710</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/888710</guid><dc:creator><![CDATA[Konrad]]></dc:creator><pubDate>Mon, 10 Oct 2005 11:07:05 GMT</pubDate></item><item><title><![CDATA[Reply to STL class vector::iterator - wie muss das aussehen? on Mon, 10 Oct 2005 12:15:45 GMT]]></title><description><![CDATA[<p>Er hat nicht gemeckert, aber ursprünglich hatte ich auch das &lt;T&gt; drin.<br />
Den Code musste ic abtippen, da ich mal wieder am Laptop arbeite und der momnentan kein Internet hat..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/888777</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/888777</guid><dc:creator><![CDATA[DocJunioR]]></dc:creator><pubDate>Mon, 10 Oct 2005 12:15:45 GMT</pubDate></item><item><title><![CDATA[Reply to STL class vector::iterator - wie muss das aussehen? on Mon, 10 Oct 2005 16:53:13 GMT]]></title><description><![CDATA[<p>Konrad schrieb:</p>
<blockquote>
<p>Geht das wirklich?</p>
<pre><code>vector&lt;cTree*&gt; child;
</code></pre>
</blockquote>
<p>Ja. Dank &quot;class name injection&quot; ist der Name einer Templateklasse innerhalb der Klassendefinition äquivalent zu Templatename&lt;Template-ParameterListe&gt;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/889043</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/889043</guid><dc:creator><![CDATA[HumeSikkins]]></dc:creator><pubDate>Mon, 10 Oct 2005 16:53:13 GMT</pubDate></item></channel></rss>