读书人

`out_of_range#039; has not been declare

发布时间: 2012-03-08 13:30:13 作者: rapoo

`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> 

读书人网 >C++

热点推荐