小弟我这个小的程序编译为什么有错啊多谢
求助:我这个小的程序编译为什么有错啊,谢谢!
请教:
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)
...
------解决方案--------------------
对
就是这样
请教:
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)
...
------解决方案--------------------
对
就是这样