<?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[Try-catch-Versuche stürtzen immer ab wieso?]]></title><description><![CDATA[<p>hallo ich wollte mich nun mal darum bemuehen mich mit ausnahmebehandlungen auseinander zu setzen und habe hier zu mal eine einfache anwendung geschrieben.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
    using namespace std;

#pragma hdrstop
#pragma argsused

int add( int, int );

class error {

};
int main( int argc, char* argv[] ) {

    int x, y, erg;
    bool flag = true;

    do {
    try {

        cout &lt;&lt; &quot;\n Enter here two positv values!\n&quot; &lt;&lt; endl;
        cin &gt;&gt; x &gt;&gt; y;
        erg = add( x, y );
    }

    catch( string &amp;s ) {

        cerr &lt;&lt; s &lt;&lt; endl;
        cin.sync();
        cin.clear();
        getchar();
    }

    catch( error&amp; ) {

        cerr &lt;&lt; &quot;Division durch 0&quot; &lt;&lt; endl;
        cin.sync();
        cin.clear();
        getchar();
    }

    catch( ... ) {

        cerr &lt;&lt; &quot;Undefine error&quot; &lt;&lt; endl;
        cin.sync();
        cin.clear();
        getchar();
        flag = false;

    }
        cout &lt;&lt; &quot; Ergebnis: &quot; &lt;&lt; erg &lt;&lt; endl;

    } while( flag );

    return 0;
}

int add( int a, int b ) {

    if( b &lt; 0 ) {

        throw (string) &quot; Negativer Nenner!&quot;;
    }
    else if( b == 0 ) {

        error er;
        throw er;
    }
    return( (a / b ) );
}
</code></pre>
<p>so, lässt sich problemlos compilieren und wenn ich die anweisungen beachte also kein negativen nenner oder einen der !=0 ist arbeitet das prog ohne probleme. doch wollte ich ja gerade die ausnahmebehandlungen ausprobieren. also mache ich absichtlich einen fehler bleibt er immer bei den throw befehlen hängen und das prog kackt ab und es erscheint bei mir eine DlgBox &quot;Step&amp;Run&quot; ect. also wieso bleibt er bei throw immer hängen??, fuer hilfe bin ich dankbar</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/166739/try-catch-versuche-stürtzen-immer-ab-wieso</link><generator>RSS for Node</generator><lastBuildDate>Tue, 15 Sep 2026 17:01:53 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/166739.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 02 Dec 2006 09:35:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Try-catch-Versuche stürtzen immer ab wieso? on Sat, 02 Dec 2006 09:35:36 GMT]]></title><description><![CDATA[<p>hallo ich wollte mich nun mal darum bemuehen mich mit ausnahmebehandlungen auseinander zu setzen und habe hier zu mal eine einfache anwendung geschrieben.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
    using namespace std;

#pragma hdrstop
#pragma argsused

int add( int, int );

class error {

};
int main( int argc, char* argv[] ) {

    int x, y, erg;
    bool flag = true;

    do {
    try {

        cout &lt;&lt; &quot;\n Enter here two positv values!\n&quot; &lt;&lt; endl;
        cin &gt;&gt; x &gt;&gt; y;
        erg = add( x, y );
    }

    catch( string &amp;s ) {

        cerr &lt;&lt; s &lt;&lt; endl;
        cin.sync();
        cin.clear();
        getchar();
    }

    catch( error&amp; ) {

        cerr &lt;&lt; &quot;Division durch 0&quot; &lt;&lt; endl;
        cin.sync();
        cin.clear();
        getchar();
    }

    catch( ... ) {

        cerr &lt;&lt; &quot;Undefine error&quot; &lt;&lt; endl;
        cin.sync();
        cin.clear();
        getchar();
        flag = false;

    }
        cout &lt;&lt; &quot; Ergebnis: &quot; &lt;&lt; erg &lt;&lt; endl;

    } while( flag );

    return 0;
}

int add( int a, int b ) {

    if( b &lt; 0 ) {

        throw (string) &quot; Negativer Nenner!&quot;;
    }
    else if( b == 0 ) {

        error er;
        throw er;
    }
    return( (a / b ) );
}
</code></pre>
<p>so, lässt sich problemlos compilieren und wenn ich die anweisungen beachte also kein negativen nenner oder einen der !=0 ist arbeitet das prog ohne probleme. doch wollte ich ja gerade die ausnahmebehandlungen ausprobieren. also mache ich absichtlich einen fehler bleibt er immer bei den throw befehlen hängen und das prog kackt ab und es erscheint bei mir eine DlgBox &quot;Step&amp;Run&quot; ect. also wieso bleibt er bei throw immer hängen??, fuer hilfe bin ich dankbar</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1185672</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1185672</guid><dc:creator><![CDATA[T0bi]]></dc:creator><pubDate>Sat, 02 Dec 2006 09:35:36 GMT</pubDate></item><item><title><![CDATA[Reply to Try-catch-Versuche stürtzen immer ab wieso? on Sat, 02 Dec 2006 11:01:14 GMT]]></title><description><![CDATA[<p>Ja dann mach doch mal &quot;Run&quot; <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Beim VS2005 kann man einstellen, dass der Debugger anspringt wenn Exceptions fliegen, damit Du Dir den Kontext genau ansehen kannst (könnte ja auch ein logischer Fehler im Programm sein). Kann man aber (Menü Debug-&gt;Exceptions imho) auch abschalten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1185701</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1185701</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Sat, 02 Dec 2006 11:01:14 GMT</pubDate></item><item><title><![CDATA[Reply to Try-catch-Versuche stürtzen immer ab wieso? on Sat, 02 Dec 2006 11:11:55 GMT]]></title><description><![CDATA[<p>Was issen das für ne Ausdrucksweise? &quot;kackt ab&quot;...</p>
<p>Naja, wenn du mal einen Button in dem Dialog gedrückt hättest, wüsstest du das das Programm nicht abgestürzt ist. Ist nur eine Hilfestellung der IDE.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1185713</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1185713</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Sat, 02 Dec 2006 11:11:55 GMT</pubDate></item><item><title><![CDATA[Reply to Try-catch-Versuche stürtzen immer ab wieso? on Sat, 02 Dec 2006 11:23:17 GMT]]></title><description><![CDATA[<p>hmm ok... danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1185725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1185725</guid><dc:creator><![CDATA[T0bi]]></dc:creator><pubDate>Sat, 02 Dec 2006 11:23:17 GMT</pubDate></item><item><title><![CDATA[Reply to Try-catch-Versuche stürtzen immer ab wieso? on Sat, 02 Dec 2006 13:06:46 GMT]]></title><description><![CDATA[<p>Das (string)&quot;blablabla&quot; sieht auf jeden Fall schonmal ungünstig aus. Dann doch lieber string(&quot;blablabla&quot;);</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1185786</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1185786</guid><dc:creator><![CDATA[Jester]]></dc:creator><pubDate>Sat, 02 Dec 2006 13:06:46 GMT</pubDate></item></channel></rss>