今天在使用CodeBlocks编译器时,对于下面的代码
public:
SmallInt(int i=0):val(i){
if(i<0||i>255)
throw out_of_range("error");
}
编译器报错:
error: 'out_of_range' was not declared in this scope
在使用VS2010时这个错误是没有的,在此编译器中的解决办法是添加头文件#include<stdexcept>即可。
转载于:https://blog.51cto.com/beyond316/1229777