16,472
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include "afxwin.h"
using namespace std;
int main()
{
TRY
{
CFile file(_T("C:\\1.txt"), CFile::modeRead); // 构造CFile对象file,并以只读模式打开一个文件,如果不存在则抛出CFileException异常
}
CATCH (CFileException, e)
{
if (e->m_cause == CFileException::fileNotFound)
{
// 如果捕获到CFileException异常且为文件未找到时,弹出提示对话框
MessageBox(NULL,_T("file not found!"),_T("nihao"),MB_OK);
return 1;
}
}
END_CATCH
return 1;
}
#define CATCH(class, e) } catch (class* e) \
{ ASSERT(e->IsKindOf(RUNTIME_CLASS(class))); \
_afxExceptionLink.m_pException = e;
CATCH (CFileException, e)
Unhandled exception ... ,遇到未处理异常了吧?“CFileException, e”,中间多了一个逗号?