On Apr 17, 11:43 am, "f.las...@[EMAIL PROTECTED]
" <f.las...@[EMAIL PROTECTED]
> wrote:
> Hello to all of you,
>
> at the moment, I'm despairing! I don't know why my code doesn't work.
> Have a look:
>
> void CMyClass::DoSomething()
> {
> try
> {
> DoItNow();
> }
> catch(...)
> {
> std::cout << "Exception caught!\n";
> }
>
> }
>
> void CMyClass::DoItNow()
> {
> throw 5;
>
> }
>
> I compiled this code with -fexceptions and when I try to run it, after
> the call of DoItNow(), the programm aborts with SIGABRT.
>
> WHY???????????
>
> --
> [ Seehttp://www.gotw.ca/resources/clcm.htmfor
info about ]
> [ comp.lang.c++.moderated. First time posters: Do this! ]
Works Fine for me:
This is what I compiled:
$ cat X.cpp
#include <iostream>
struct CMyClass
{
void DoSomething();
void DoItNow();
};
void CMyClass::DoSomething()
{
try
{
DoItNow();
}
catch(...)
{
std::cout << "Exception caught!\n";
}
}
void CMyClass::DoItNow()
{
throw 5;
}
int main()
{
CMyClass x;
x.DoSomething();
}
This is my results:
$ g++ -fexceptions X.cpp
$ ./a.exe
Exception caught!
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


|