<?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[catch (out_of_range)- nur wie?]]></title><description><![CDATA[<p>Hi,</p>
<p>folgender code:</p>
<pre><code class="language-cpp">try
    {
      v_polygon.push_back(vertexList.at(i));
      index++;
    }
    catch (OUT_OF_RANGE)
    {
     // etc.
</code></pre>
<p>Angeblich wird ein out_of_range geworfen, wenn der Zugriff auf den std::vector (steht so in der Beschreibung zum std::vector)</p>
<pre><code class="language-cpp">vertexList.at(i)
</code></pre>
<p>Fehlschlägt. Leider sagt der gcc:</p>
<blockquote>
<p>Fehler: expected type-specifier before »out_of_range«</p>
</blockquote>
<p>Irgendwas habe ich also vergessen, aber was?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/148533/catch-out_of_range-nur-wie</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 20:47:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/148533.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 27 May 2006 17:58:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to catch (out_of_range)- nur wie? on Sat, 27 May 2006 17:58:49 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>folgender code:</p>
<pre><code class="language-cpp">try
    {
      v_polygon.push_back(vertexList.at(i));
      index++;
    }
    catch (OUT_OF_RANGE)
    {
     // etc.
</code></pre>
<p>Angeblich wird ein out_of_range geworfen, wenn der Zugriff auf den std::vector (steht so in der Beschreibung zum std::vector)</p>
<pre><code class="language-cpp">vertexList.at(i)
</code></pre>
<p>Fehlschlägt. Leider sagt der gcc:</p>
<blockquote>
<p>Fehler: expected type-specifier before »out_of_range«</p>
</blockquote>
<p>Irgendwas habe ich also vergessen, aber was?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1066313</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066313</guid><dc:creator><![CDATA[Physikalischer Fehler]]></dc:creator><pubDate>Sat, 27 May 2006 17:58:49 GMT</pubDate></item><item><title><![CDATA[Reply to catch (out_of_range)- nur wie? on Sat, 27 May 2006 18:01:40 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">catch (const std::out_of_range&amp; e)
</code></pre>
<p>Die Syntax von catch entspricht in etwa der einer Funktionsdeklaration.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1066316</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066316</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Sat, 27 May 2006 18:01:40 GMT</pubDate></item><item><title><![CDATA[Reply to catch (out_of_range)- nur wie? on Sat, 27 May 2006 18:06:40 GMT]]></title><description><![CDATA[<p>warum das &amp;e?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1066320</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066320</guid><dc:creator><![CDATA[Physikalischer Fehler]]></dc:creator><pubDate>Sat, 27 May 2006 18:06:40 GMT</pubDate></item><item><title><![CDATA[Reply to catch (out_of_range)- nur wie? on Sat, 27 May 2006 18:09:33 GMT]]></title><description><![CDATA[<p>by-reference. Damit die Excetion nicht by-value übergeben wird, was eine Kopie bedeuten würde und ja irgendwie schwachsinnig wäre.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1066324</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066324</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Sat, 27 May 2006 18:09:33 GMT</pubDate></item><item><title><![CDATA[Reply to catch (out_of_range)- nur wie? on Sat, 27 May 2006 18:10:31 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>weil das catch nicht nur dazu gedacht ist, eine Exception bestimmten (oder allgemeinen) Types abzufangen, sondern auch mit den Daten (also das was in der Referenz mit der Bezeichnung e steht) etwas zu machen... zum Beispiel eine Situationsangepasste Meldung ausgeben.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1066325</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066325</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sat, 27 May 2006 18:10:31 GMT</pubDate></item><item><title><![CDATA[Reply to catch (out_of_range)- nur wie? on Sat, 27 May 2006 18:10:38 GMT]]></title><description><![CDATA[<p>Sag ich doch, es ist wie eine Funktionsdeklaration. Und da du wohl kaum die Exception ändern willst (und deren Fehlertext möglicherweise groß sein kann) nimmst du eine konstante Referenz auf den Exceptiontyp (const&amp;) als Parametertyp.<br />
Das e kannst du dann im catch Block verwenden, z.B. so:</p>
<pre><code class="language-cpp">catch (const std::out_of_range&amp; e)
{
    std::cerr &lt;&lt; e.what ();
    exit (1);
}
</code></pre>
<p>Das kann dir aber auch jedes Exceptiontutorial zeigen und ein solches solltest du mal lesen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1066326</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066326</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Sat, 27 May 2006 18:10:38 GMT</pubDate></item></channel></rss>