<?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[konstante Referenz auf std::vector&amp;lt;T&amp;gt;]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich versuche folgendes:</p>
<pre><code class="language-cpp">void Typ::MacheWas() const {...;}
void blah(const vector&lt;Typ&gt;&amp; vektorRef)
{
  ...
  vektorRef[i].MacheWas();
}
</code></pre>
<p>Der Compiler meckert: &quot;this-Zeiger kann nicht von 'const std::allocator&lt;_Ty&gt;::value_type' in 'Typ &amp;' konvertiert werden with [_Ty=Typ]&quot;</p>
<p>Leider verstehe ich nicht warum dies so ist.<br />
Währe toll wenn mir jemand den Grund dafür erklären könnte und eine Alternative vorschlägt, wie ich eine konstante Referenz auf std::vector&lt;T&gt; übergeben kann und den entsprechenden Zugriff erhalte.</p>
<p>DANKE!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/191147/konstante-referenz-auf-std-vector-lt-t-gt</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 21:48:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/191147.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 30 Aug 2007 17:14:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to konstante Referenz auf std::vector&amp;lt;T&amp;gt; on Thu, 30 Aug 2007 17:14:10 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich versuche folgendes:</p>
<pre><code class="language-cpp">void Typ::MacheWas() const {...;}
void blah(const vector&lt;Typ&gt;&amp; vektorRef)
{
  ...
  vektorRef[i].MacheWas();
}
</code></pre>
<p>Der Compiler meckert: &quot;this-Zeiger kann nicht von 'const std::allocator&lt;_Ty&gt;::value_type' in 'Typ &amp;' konvertiert werden with [_Ty=Typ]&quot;</p>
<p>Leider verstehe ich nicht warum dies so ist.<br />
Währe toll wenn mir jemand den Grund dafür erklären könnte und eine Alternative vorschlägt, wie ich eine konstante Referenz auf std::vector&lt;T&gt; übergeben kann und den entsprechenden Zugriff erhalte.</p>
<p>DANKE!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1355532</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1355532</guid><dc:creator><![CDATA[Taschenlampe]]></dc:creator><pubDate>Thu, 30 Aug 2007 17:14:10 GMT</pubDate></item><item><title><![CDATA[Reply to konstante Referenz auf std::vector&amp;lt;T&amp;gt; on Thu, 30 Aug 2007 17:54:34 GMT]]></title><description><![CDATA[<p>Hi,<br />
folgender Code klappt mit dem gcc:</p>
<pre><code class="language-cpp">#include &lt;vector&gt;
#include &lt;iostream&gt;

using namespace std;

class test
{
public:
    void machwas() const {cout &lt;&lt; &quot;Hallo&quot;;}
};

void f(const vector&lt;test&gt; &amp;tests)
{
    tests[0].machwas();
}

int main()
{
        test t;
        vector&lt;test&gt; tests;
        tests.push_back(t);
        f(tests);
}
</code></pre>
<p>Sorry für den beschissenen Code, aber er zeigt das nötigste.</p>
<p>KaPtainCugel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1355569</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1355569</guid><dc:creator><![CDATA[KPC]]></dc:creator><pubDate>Thu, 30 Aug 2007 17:54:34 GMT</pubDate></item><item><title><![CDATA[Reply to konstante Referenz auf std::vector&amp;lt;T&amp;gt; on Thu, 30 Aug 2007 18:08:38 GMT]]></title><description><![CDATA[<p>Das ist doch das Gleiche was ich mache.<br />
Nur nimmt der MSVC++ 2003 das wie beschrieben nicht entgegen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1355581</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1355581</guid><dc:creator><![CDATA[Taschenlampe]]></dc:creator><pubDate>Thu, 30 Aug 2007 18:08:38 GMT</pubDate></item><item><title><![CDATA[Reply to konstante Referenz auf std::vector&amp;lt;T&amp;gt; on Thu, 30 Aug 2007 18:26:49 GMT]]></title><description><![CDATA[<p>Also in VS2005 funktionert es. Ich habe aber auch bei der Funktion mach was das const dabei, has hastde aber auch also könnts wohl ein fehler im VC2003 sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1355594</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1355594</guid><dc:creator><![CDATA[fgsdgdfg]]></dc:creator><pubDate>Thu, 30 Aug 2007 18:26:49 GMT</pubDate></item><item><title><![CDATA[Reply to konstante Referenz auf std::vector&amp;lt;T&amp;gt; on Thu, 30 Aug 2007 18:28:08 GMT]]></title><description><![CDATA[<p>Aber der fehlermeldung nach sieht halt so aus, dass das const bei der aufgerufenen funktion fehlt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1355595</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1355595</guid><dc:creator><![CDATA[dffdgdfg]]></dc:creator><pubDate>Thu, 30 Aug 2007 18:28:08 GMT</pubDate></item><item><title><![CDATA[Reply to konstante Referenz auf std::vector&amp;lt;T&amp;gt; on Thu, 30 Aug 2007 18:30:01 GMT]]></title><description><![CDATA[<p>Bah!</p>
<p>Sorry - hatte leider die falsche Definition der MacheWas() Funktion in den Augen.<br />
Die ich nutze war nicht als konstant deklariert.</p>
<p>Tut mir leid um Eure Zeit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1355597</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1355597</guid><dc:creator><![CDATA[Taschenlampe]]></dc:creator><pubDate>Thu, 30 Aug 2007 18:30:01 GMT</pubDate></item></channel></rss>