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

`out_of_range' has not been declared,该如何解决

2012-03-08 
`out_of_range has not been declared如下代码,在VS2010下运行正常,但是,在CFree(mingw5)运行就会出现 `o

`out_of_range' has not been declared
如下代码,在VS2010下运行正常,但是,在CFree(mingw5)运行就会出现 `out_of_range' has not been declared的问题,请问下,这是什么原因呢?要如何做才能正常运行?

C/C++ code
#include <iostream>#include <string> using namespace std; int main() {     string s="what is your name?";     int index, len;     while(true)     {         cout<<"Enter index and len to erase: ";         cin>>index>>len;         try         {             s.erase(index,len);         }         catch(out_of_range)         {             cout<<"out of range!!!";            continue;         }         break;     }        return 0; }


[解决办法]
C/C++ code
#include <stdexcept> 

热点排行