try...catch问题

jstones 2006-02-27 10:17:59
第一次用,请教。
try{...........
.................
...........
}
catch ( CFileException, e ){
AfxMessageBox( "dddddddddddd!");
return FALSE;
}

编译出错:
Compiling...
SPCModuleInterface.cpp
D:\face.cpp(165) : warning C4101: 'strTemp1' : unreferenced local variable
D:\face.cpp(164) : warning C4101: 'ntemp1' : unreferenced local variable
D:\face.cpp(252) : error C2143: syntax error : missing ';' before 'try'
D:\face.cpp(252) : error C2143: syntax error : missing ';' before '{'
D:\face.cpp(252) : error C2447: missing function header (old-style formal list?)
D:\face.cpp(258) : error C2143: syntax error : missing ';' before 'catch'
D:\face.cpp(258) : error C2143: syntax error : missing ';' before '{'
D:\face.cpp(258) : error C2447: missing function header (old-style formal list?)
...全文
221 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
gflpower 2006-03-02
  • 打赏
  • 举报
回复
#include <exception>

using namespace std;



具体了这两条之后才可以使异常处理语句
jacklzw88 2006-03-02
  • 打赏
  • 举报
回复
全部代码写出来,一看就知道其它地方有错
jstones 2006-03-02
  • 打赏
  • 举报
回复
帮帮忙。
有谁知道么。
折腾_苏州 2006-02-28
  • 打赏
  • 举报
回复
catch ( CFileException, e )???

CFileException e 是 将捕获的异常放在一个CFileException类型的变量e中,以便用他来做一些异常的处理,比如显示错误信息等,你 加个逗号做甚?
daiybh 2006-02-28
  • 打赏
  • 举报
回复
逗号
jstones 2006-02-28
  • 打赏
  • 举报
回复
还是不行。
arrow8209 2006-02-28
  • 打赏
  • 举报
回复
你试试这样写catch(...)
jstones 2006-02-28
  • 打赏
  • 举报
回复
我去了“,”
可还是那个错误。
用catch (Exception e)
也出错。

++++++
我是在调用dll文件时捕获他的异常;
try{
int face::Create(INPUT * pInput,OUTPUT * pOutput)
{
return 。。。。。。。。。。。。。。。
。。。。。。
}
}
catch ( _com_error &e ){
DisplayError(e);
AfxMessageBox( "dddddddddddd!");
return FALSE;
}

--------------------Configuration: Server - Win32 Debug--------------------
Compiling...
face.cpp
D:\face.cpp(165) : warning C4101: 'strTemp1' : unreferenced local variable
D:\face.cpp(164) : warning C4101: 'ntemp1' : unreferenced local variable
D:\face.cpp(251) : error C2143: syntax error : missing ';' before 'try'
D:\face.cpp(251) : error C2143: syntax error : missing ';' before '{'
D:\face.cpp(251) : error C2447: missing function header (old-style formal list?)
D:\face.cpp(257) : error C2143: syntax error : missing ';' before 'catch'
D:\face.cpp(257) : error C2143: syntax error : missing ';' before '{'
D:\face.cpp(257) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.
Creating browse info file...

Server.exe - 6 error(s), 2 warning(s)
妍妍 2006-02-28
  • 打赏
  • 举报
回复
CFileException, e //去掉逗号
joinclear 2006-02-27
  • 打赏
  • 举报
回复
CFileException, e
逗号去了
jstones 2006-02-27
  • 打赏
  • 举报
回复
如果不用try...catch,程序运行正常。

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧