斐伊川处理的问题,我是新来的C++编程,需要有关我下面写的代码一些帮助.... 它是一种基本的异常处理程序异常在C++
#include<iostream>
class range_error
{
public:
int i;
range_error(int x){i=x;}
}
int compare(int x)
{
if(x<100)
throw range_error(x);
return x;
}
int main()
{
int a;
std::cout<<"Enter a ";
std::cin>>a;
try
{
compare(a);
}
catch(range_error)
{
std::cout<<"Exception caught";
}
std::cout<<"Outside the try-catch block";
std::cin.get();
return 0;
}
当我编译这个.. 。我得到这个...
新类型可能没有在第11行的返回类型中定义(在比较函数的开始处)。
请给我解释一下什么是错的...
我希望你的代码是不实际的格式,它随机。 – GManNickG 2010-10-24 07:14:50