<?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 von Vektor als Rückgabewert]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich hab in einer Klasse eine Funktion die mitm Sieb des Erathosthenes Primzahlen berechnet.<br />
Jetzt stellt sich mir natürlich die frage ob ich einen iterator auf den vector zurückgeben kann... wäre ja auch so ne feine sache um eine bestimmte position im vector zu behalten.</p>
<p>und wie würde das aussehen? könnte mir da einfach jemand ganz kurz ne quellcode-skizze zu bauen?</p>
<p>MfG<br />
Bara <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/251899/iterator-von-vektor-als-rückgabewert</link><generator>RSS for Node</generator><lastBuildDate>Tue, 15 Sep 2026 06:46:36 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/251899.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 12 Oct 2009 11:11:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to iterator von Vektor als Rückgabewert on Mon, 12 Oct 2009 11:11:38 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich hab in einer Klasse eine Funktion die mitm Sieb des Erathosthenes Primzahlen berechnet.<br />
Jetzt stellt sich mir natürlich die frage ob ich einen iterator auf den vector zurückgeben kann... wäre ja auch so ne feine sache um eine bestimmte position im vector zu behalten.</p>
<p>und wie würde das aussehen? könnte mir da einfach jemand ganz kurz ne quellcode-skizze zu bauen?</p>
<p>MfG<br />
Bara <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/1791305</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1791305</guid><dc:creator><![CDATA[Barados]]></dc:creator><pubDate>Mon, 12 Oct 2009 11:11:38 GMT</pubDate></item><item><title><![CDATA[Reply to iterator von Vektor als Rückgabewert on Mon, 12 Oct 2009 11:16:24 GMT]]></title><description><![CDATA[<p>Mitm Iterator ist das immer so eine Sache. Der ist nur gültig, solange man mitm Vector keine Einfügungen mehr macht. Ich fahre mitm int oder size_t da auch ganz gut.<br />
Allerdings kann ich mir nicht vorstellen, wo eine Funktion die mitm Sieb des Erathosthenes Primzahlen berechnet, sowas brauchen könnte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1791310</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1791310</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Mon, 12 Oct 2009 11:16:24 GMT</pubDate></item><item><title><![CDATA[Reply to iterator von Vektor als Rückgabewert on Mon, 12 Oct 2009 11:20:32 GMT]]></title><description><![CDATA[<p>beispiel:</p>
<p>ich fülle erstmal meinen std::vector.<br />
in einer anderen funktion geh ich diesen vector ab (beispielsweise um eine primzahlzerlegung zu machen) und möchte dann den letzten primfaktor zurückgeben.<br />
da kann ich nen int zurückgeben oder auch einen iterator der auf diese stelle zeigt.</p>
<p>mir gehts da auch eher um die machbarkeit.</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1791312</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1791312</guid><dc:creator><![CDATA[Barados]]></dc:creator><pubDate>Mon, 12 Oct 2009 11:20:32 GMT</pubDate></item><item><title><![CDATA[Reply to iterator von Vektor als Rückgabewert on Mon, 12 Oct 2009 11:26:46 GMT]]></title><description><![CDATA[<p>Das geht und ist ok.</p>
<pre><code class="language-cpp">//Rückgabe: Iterator auf Primzahl, die den kleinsten Primfaktor von n darstellt, 
//oder primzahlenliste.end(), wenn n eine Primzahl ist. 
Vector&lt;int&gt;::iterator ersterPrimfaktor(int n){
   Vector&lt;int&gt;::iterator i=primzahlenliste.begin();
   for(;i!=primzahlenliste.end();++i)
      if(n%*i==0 &amp;&amp; n&gt;*i)
         break;
   return i;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1791315</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1791315</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Mon, 12 Oct 2009 11:26:46 GMT</pubDate></item><item><title><![CDATA[Reply to iterator von Vektor als Rückgabewert on Mon, 12 Oct 2009 11:31:43 GMT]]></title><description><![CDATA[<p>hättest du da evtl auch nen kleines bisserl code für mich?</p>
<p>ich stell mir das so vor:</p>
<pre><code class="language-cpp">void Class::takeIT()
{
...
  std::vector&lt;int&gt;::iterator it;
  it = putIT();
  ...
}

Iterator Class::putIT()
{
  std::vector&lt;int&gt;::iterator it;
  it=myVector.begin();
  return it;
}
</code></pre>
<p>?</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1791317</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1791317</guid><dc:creator><![CDATA[Barados]]></dc:creator><pubDate>Mon, 12 Oct 2009 11:31:43 GMT</pubDate></item><item><title><![CDATA[Reply to iterator von Vektor als Rückgabewert on Mon, 12 Oct 2009 12:07:38 GMT]]></title><description><![CDATA[<p>Na, der Rückgabetyp ist dir doch schon bekannt:</p>
<pre><code class="language-cpp">void Class::takeIT()
{
...
  std::vector&lt;int&gt;::iterator it;
  it = putIT();
  ...
}

std::vector&lt;int&gt;::iterator Class::putIT()
{
  std::vector&lt;int&gt;::iterator it;
  it=myVector.begin();
  return it;
}
</code></pre>
<p>Warum gehst du so verschwenderich mit Initialisierungen um?</p>
<pre><code class="language-cpp">void Class::takeIT()
{
...
  std::vector&lt;int&gt;::iterator it = putIT();
  ...
}

std::vector&lt;int&gt;::iterator Class::putIT()
{
  std::vector&lt;int&gt;::iterator it =myVector.begin();
  return it;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1791341</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1791341</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Mon, 12 Oct 2009 12:07:38 GMT</pubDate></item></channel></rss>