首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

小弟我这个小的程序编译为什么有错啊多谢

2012-04-07 
求助:我这个小的程序编译为什么有错啊,谢谢!请教:win32控制台程序#includestdafx.h #includeiostreamu

求助:我这个小的程序编译为什么有错啊,谢谢!
请教:
win32   控制台程序

#include   "stdafx.h "
#include   <iostream>

using   namespace   std;


int   main(void)
{
int   i;
i=   5;

        try
              {
      //   if   (i   > 2)
              //   {
                    throw   1;
//}

}

        catch   (   1   )

        {
                cout   < <   "catch   ... "   < <   endl;

        }
cin.get();
return   1;
}

编译时提示的错误是:
--------------------Configuration:   test1   -   Win32   Debug--------------------
Compiling...
test1.cpp
C:\异常测试\test1\test1.cpp(23)   :   error   C2059:   syntax   error   :   'constant '
C:\异常测试\test1\test1.cpp(23)   :   error   C2310:   catch   handlers   must   specify   one   type
C:\异常测试\test1\test1.cpp(29)   :   error   C2317:   'try '   block   starting   on   line   '16 '   has   no   catch   handlers
Error   executing   cl.exe.

test1.exe   -   3   error(s),   0   warning(s)


我是错在哪里啊?
谢谢!


[解决办法]

catch (int n) //捕获的是类型
{
....
}
[解决办法]
补充:此时 n的值为1
[解决办法]
if (n == 1)
...
[解决办法]

就是这样

热点排行