Re: question on try/catch
From: modemer (modemer_at_yahoo.com)
Date: 03/05/05
- Previous message: Phil Staite: "Re: question on try/catch"
- In reply to: xuatla: "question on try/catch"
- Next in thread: Rolf Magnus: "Re: question on try/catch"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 4 Mar 2005 21:33:52 -0500
"xuatla" <xuatla@gmail.com> ??????:d0b4rc$ho5$1@daisy.noc.ucla.edu...
> Hi,
>
> I tried the following code about try/catch (from cplusplus.com)
>
> // exceptions
> #include <ciostream>
> using namespace std;
>
> int main () {
> char myarray[10];
> try
> {
> for (int n=0; n<=10; n++)
> {
> if (n>9) throw "Out of range";
> myarray[n]='z';
> }
> }
> catch (char * str)
should be:
catch (char const *str)
> {
> cout << "Exception: " << str << endl;
> }
> return 0;
> }
>
> It's expected to give "Exception: Out of range".
> but i complied in g++ 3.3.3. and run it, the output is "Aborted".
>
> Anyone help me to explain what's wrong here? or normal?
>
> Thanks a lot!
>
> xuatla
- Previous message: Phil Staite: "Re: question on try/catch"
- In reply to: xuatla: "question on try/catch"
- Next in thread: Rolf Magnus: "Re: question on try/catch"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|