C (162/301)

From:andrewmarkwell
Date:26 Aug 99 at 15:28:18
Subject:Re: ExecBase & 'RESET:starting PC' exception

From: andrewmarkwell@ukonline.co.uk

>From: Gabriele Svelto <jlpicard@tiscalinet.it>
>
> Hello everybody,

>BTW, what are exceptions in C++? I'm learning C++ now but I haven't found
>anything about that in the book I'm reading (maybe it's because it is a
>little bit outdated, 1990...).
>
You can use exceptions like this:

void main(void)
{
try
{
blahblah=somecode();
if(!blahblah)
throw "something went wrong";
}
catch(char *error)
{
cout << error;
}
}

They're mainly used for error handling.. an easy way to jump out of a block of code. Note that you could have many other 'catch' blocks, that may take, say, an int, or any other datatype. try/catch blocks can be nested too, so you don't have to use them in main() only.