<?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[Kann Element nicht aus Vektor löschen]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich bräuchte mal kurz Hilfe.<br />
Ich hab eine Template-Klasse:</p>
<pre><code class="language-cpp">template&lt; typename T &gt;
class Foo
{
   private:
      std::vector&lt;T*&gt; elemente;

   public:
      bool deleteElement( size_t id )
      {
         if( id &gt;= this-&gt;elemente.size() )
            return false;

         std::vector&lt;T*&gt;::iterator it = this-&gt;elemente.begin() + id; //Zeile 188
         this-&gt;elemente.erase( it );
         return true;
      }
};
</code></pre>
<p>Wenn ich kompilieren will kommt folgende Meldung die ich nicht verstehe:<br />
`In member function ‘bool Foo&lt;T&gt;::deleteElement(size_t)’:</p>
<p>188  error: expected ‘;’ before ‘it’</p>
<p>189  error: ‘it’ was not declared in this scope</p>
<p>||=== Build finished: 2 errors, 0 warnings ===|`</p>
<p>Was hat das zu bedeuten? Was ist an den zwei Zeilen falsch? Ich will doch nur ein Element aus dem Vektor löschen...</p>
<p>MfG. Ich</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/258524/kann-element-nicht-aus-vektor-löschen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 09:52:09 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/258524.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 11 Jan 2010 20:05:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Kann Element nicht aus Vektor löschen on Mon, 11 Jan 2010 20:05:09 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich bräuchte mal kurz Hilfe.<br />
Ich hab eine Template-Klasse:</p>
<pre><code class="language-cpp">template&lt; typename T &gt;
class Foo
{
   private:
      std::vector&lt;T*&gt; elemente;

   public:
      bool deleteElement( size_t id )
      {
         if( id &gt;= this-&gt;elemente.size() )
            return false;

         std::vector&lt;T*&gt;::iterator it = this-&gt;elemente.begin() + id; //Zeile 188
         this-&gt;elemente.erase( it );
         return true;
      }
};
</code></pre>
<p>Wenn ich kompilieren will kommt folgende Meldung die ich nicht verstehe:<br />
`In member function ‘bool Foo&lt;T&gt;::deleteElement(size_t)’:</p>
<p>188  error: expected ‘;’ before ‘it’</p>
<p>189  error: ‘it’ was not declared in this scope</p>
<p>||=== Build finished: 2 errors, 0 warnings ===|`</p>
<p>Was hat das zu bedeuten? Was ist an den zwei Zeilen falsch? Ich will doch nur ein Element aus dem Vektor löschen...</p>
<p>MfG. Ich</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1837067</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1837067</guid><dc:creator><![CDATA[ChristophLu]]></dc:creator><pubDate>Mon, 11 Jan 2010 20:05:09 GMT</pubDate></item><item><title><![CDATA[Reply to Kann Element nicht aus Vektor löschen on Mon, 11 Jan 2010 20:35:35 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">typename std::vector&lt;T*&gt;::iterator it = this-&gt;elemente.begin() + id;
</code></pre>
<p>Hintergrund zur Problematik:<br />
<a href="http://pages.cs.wisc.edu/~driscoll/typename.html" rel="nofollow">http://pages.cs.wisc.edu/~driscoll/typename.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1837100</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1837100</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 11 Jan 2010 20:35:35 GMT</pubDate></item></channel></rss>