懂一点点c++的帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/07 02:02:04
下面是一个演示c++异常处理机制的小程序,我照书上抄的,但是compile后有如下错误提示:--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
C:\Documents and Settings\s1.C00\桌面\Cpp1.cpp(30) : error C2601: 'inputdata' : local function definitions are illegal
C:\Documents and Settings\s1.C00\桌面\Cpp1.cpp(43) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

Cpp1.obj - 2 error(s), 0 warning(s)
下面是源程序
#include <iostream.h>
#include <ctype.h>
int inputdata(void);
int main()
{
int value;
int continueflag=1;
cout<<"~~~exception handing~~~"<<endl;
while (continueflag)
{
try{
value=inputdata();
cout<<"you enter"<<value<<".everything is fine."<<endl;
continueflag=0;
}
catch (int zero){
cerr<<

仔细检查你的程序.

cout <<"end of my act !:-)";
return 0;
}
后面漏掉了半个大括号,导致
int inputdata(void)
被误写入了主函数中,只要在
cout <<"end of my act !:-)";
return 0;
}
后面再加个}就可以了呵呵
是你抄错了.
建议以后可以把大括号分层配对,把同层的大括号放在一个垂直线上
方便查找错误.

大哥这是懂一点点能看懂的吗!?