16,472
社区成员
发帖
与我相关
我的任务
分享
TRY
{
}
CATCH(CException, pEx)
{
// Simply show an error message to the user.
pEx->ReportError();
}
// exceptions_trycatchandthrowstatements.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;
int main() {
char *buf;
try {
buf = new char[512];
if( buf == 0 )
throw "Memory allocation failure!";
}
catch( char * str ) {
cout << "Exception raised: " << str << '\n';
}
}