please dont rip this site

Language Ccpp Cppref Examples Throw.cc

 
/**************************************************************************
 *
 * Language: C++
 * Purpose:  Program to demonstrate the 'try', 'catch' and 'throw' statements.
 * Author:   M J Leslie
 * Date:     21-Mar-98
 *
 * Compile:  The following command was used to compile.
 *
 *                  g++ -fhandle-exceptions throw.cc -o throw
 *
 **************************************************************************/

#include <iostream.h>                  // For cout.

void ErrorFunc(int Error);

main()
{
    ErrorFunc(0);
    ErrorFunc(1);
}
void ErrorFunc(int Error)
{
    try
    {
        cout << "Error code is " << Error << endl;

        if (Error > 0 )
        {
            throw(Error);        // This statement causes control to jump
                                 // to the 'catch' statement
        }

        cout << "No Error occoured" << endl;

    }
    catch(int n)
    {
        cout << "Error number is " << n << endl;;
    }
}


file: /Techref/language/ccpp/cppref/EXAMPLES/throw.cc, 0KB, , updated: 1998/3/21 14:56, local time: 2024/11/5 05:34,
TOP NEW HELP FIND: 
18.222.82.221:LOG IN
©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://linistepper.com/techref/language/ccpp/cppref/EXAMPLES/throw.cc"> language ccpp cppref EXAMPLES throw</A>

Did you find what you needed?