CException is the base type of all exceptions thrown by VC++, so it should catch all the exceptions, right?
CException is the base type of all exceptions thrown by VC++, so it should
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
CExceptionis not the base type for all extensions (it might be the base type of all exceptions that MFC code uses, but that’s as far as it goes).In C++, you can throw anything; it doesn’t have to be an “exception” subclass, and it does not even have to be an object. It’s perfectly legal for example to write
throw 42;orthrow new std::vector<string>();The difference is then obvious:
catch(CException)will catch only thrown instances ofCExceptionand its subclasses, while the other will catch anything.