斐伊川處理的問題,我是新來的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