More questions about exceptions
Hello, I have 2 questions:
Is it possible to catch an exception if it's thrown by a thread?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
DWORD WINAPI Thread(LPVOID lp)
{
cout <<"Exception will be thrown after "<<4;
for(int i=3;i>=0;--i)
{
cout <<"\b \b"<<i;
Sleep(1000);
}
cout <<endl;
throw(911);
}
int main()
{
try{
CreateThread(0,0,Thread,0,0,0);
}
catch(...)
{
cout <<"Exception catched"<<endl;
}
for(;;);
}
| |
Is it possible to catch this kind of exception?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
void will_throw()
{
throw(112);
}
void will_not_throw() throw()
{
will_throw();
}
int main()
{
try
{
will_not_throw();
}
catch(...)
{
cout <<"In catch"<<endl; // although exception is thrown, this catch(...) is not getting excuted
}
}
| |
Thanks for help!
1. No.
2. Don't use exception specifications.
Topic archived. No new replies allowed.