<?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[Const-Iterator?]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich hab mal wider ein Problem. Ich krieg die Meldung:</p>
<blockquote>
<p>In function `std::ostream&amp; operator&lt;&lt;(std::ostream&amp;, const<br />
Aktiengruppe&amp;)':<br />
aktiengruppe.cpp:30: error: no match for 'operator=' in 'it = std::list&lt;_Tp,_Alloc&gt;::begin() const [with _Tp = Aktie, _Alloc = std::allocator&lt;Aktie&gt;]()'<br />
/usr/include/g++/bits/stl_list.h:144: error: candidates are:<br />
std::_List_iterator&lt;Aktie, Aktie&amp;, Aktie*&gt;&amp; std::_List_iterator&lt;Aktie, Aktie&amp;, Aktie*&gt;::operator=(const std::_List_iterator&lt;Aktie, Aktie&amp;, Aktie*&gt;&amp;)</p>
</blockquote>
<p>Hier meine Code:</p>
<pre><code class="language-cpp">class Aktiengruppe
{
public:
	Aktiengruppe();
	~Aktiengruppe();
	std::list&lt;Aktie&gt; aktien;
};

std::ostream&amp; operator &lt;&lt; (std::ostream&amp; os, const Aktiengruppe&amp; gruppe)
{
	std::list&lt;Aktie&gt;::iterator it;
	for(it = (gruppe.aktien).begin(); it != (gruppe.aktien).end(); it++ )
	{
		os &lt;&lt; it-&gt;bezeichnung &lt;&lt; std::endl;
	}
	return os;
}
</code></pre>
<p>Meine Interpretation:<br />
Da die Aktiengruppe als const-Referenz übergeben wird, muss der Iterator it das berücksichtigen und auch irgendwie const sein. Aber wie? Oder ist das völlig falsch?</p>
<p>Gruss, Karl</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/131061/const-iterator</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 00:09:06 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/131061.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 30 Dec 2005 15:33:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Const-Iterator? on Fri, 30 Dec 2005 15:33:13 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich hab mal wider ein Problem. Ich krieg die Meldung:</p>
<blockquote>
<p>In function `std::ostream&amp; operator&lt;&lt;(std::ostream&amp;, const<br />
Aktiengruppe&amp;)':<br />
aktiengruppe.cpp:30: error: no match for 'operator=' in 'it = std::list&lt;_Tp,_Alloc&gt;::begin() const [with _Tp = Aktie, _Alloc = std::allocator&lt;Aktie&gt;]()'<br />
/usr/include/g++/bits/stl_list.h:144: error: candidates are:<br />
std::_List_iterator&lt;Aktie, Aktie&amp;, Aktie*&gt;&amp; std::_List_iterator&lt;Aktie, Aktie&amp;, Aktie*&gt;::operator=(const std::_List_iterator&lt;Aktie, Aktie&amp;, Aktie*&gt;&amp;)</p>
</blockquote>
<p>Hier meine Code:</p>
<pre><code class="language-cpp">class Aktiengruppe
{
public:
	Aktiengruppe();
	~Aktiengruppe();
	std::list&lt;Aktie&gt; aktien;
};

std::ostream&amp; operator &lt;&lt; (std::ostream&amp; os, const Aktiengruppe&amp; gruppe)
{
	std::list&lt;Aktie&gt;::iterator it;
	for(it = (gruppe.aktien).begin(); it != (gruppe.aktien).end(); it++ )
	{
		os &lt;&lt; it-&gt;bezeichnung &lt;&lt; std::endl;
	}
	return os;
}
</code></pre>
<p>Meine Interpretation:<br />
Da die Aktiengruppe als const-Referenz übergeben wird, muss der Iterator it das berücksichtigen und auch irgendwie const sein. Aber wie? Oder ist das völlig falsch?</p>
<p>Gruss, Karl</p>
]]></description><link>https://www.c-plusplus.net/forum/post/952867</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/952867</guid><dc:creator><![CDATA[Karl Blau]]></dc:creator><pubDate>Fri, 30 Dec 2005 15:33:13 GMT</pubDate></item><item><title><![CDATA[Reply to Const-Iterator? on Fri, 30 Dec 2005 15:34:13 GMT]]></title><description><![CDATA[<p>std::list&lt;Aktie&gt;::const_iterator it;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/952869</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/952869</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 30 Dec 2005 15:34:13 GMT</pubDate></item><item><title><![CDATA[Reply to Const-Iterator? on Fri, 30 Dec 2005 15:41:26 GMT]]></title><description><![CDATA[<p>wow - das ging ja schnell<br />
Vielen Dank,</p>
<p>Karl</p>
]]></description><link>https://www.c-plusplus.net/forum/post/952881</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/952881</guid><dc:creator><![CDATA[Karl Blau]]></dc:creator><pubDate>Fri, 30 Dec 2005 15:41:26 GMT</pubDate></item></channel></rss>