【C++标准I/0库】错误:runtime_error was not declared
来源:互联网 发布:共产主义社会 知乎 编辑:程序博客网 时间:2024/06/10 23:51
# 编译出现:runtime_error was not declared
#include <iostream>//#include <stdexcept> //runtime_errorusing namespace std;std::istream& get(std::istream& in){ //该函数应一直读取流 int val; while (in >> val, !in.eof()){ if (in.bad()){ throw runtime_error("IO stream error!"); } if (in.fail()) { std::cerr << "Data error, try again." << std::endl; in.clear(); in.ignore(200, '\n'); continue; } std::cout << "输入的数据是:" << val << std::endl; } in.clear(); return in;}int main(){ cout << "测试函数:" << endl; double d_val; //使用标准输入 get(cin); cout << "使用cin输入一个double类型的数据:" << endl; cin >> d_val; cout << "输入的是:" << d_val << endl; return 0;}错误:
||=== Build: Debug in Demo6 (compiler: GNU GCC Compiler) ===|
G:\C_Code black\day0404\Demo6\main.cpp||In function 'std::istream& get(std::istream&)':|G:\C_Code black\day0404\Demo6\main.cpp|14|error: 'runtime_error' was not declared in this scope|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
解决方法:
加上头文件:#include <stdexcept>
拓展:若出现编译错误error: 'numeric_limits' is not a member of 'std'
加上头文件:#include <limits>
0 0
- 【C++标准I/0库】错误:runtime_error was not declared
- 'dlcose' was not declared
- 'noinline' was not declared
- 使用BOOST库 多线程ThreadPool 编译错误"TIME_UTC was not declared in this scope"
- [编译错误]:exit was not declared in this scope
- C++错误“exit was not declared in this scope”
- C++ - 错误: " 'strdup' was not declared in this scope "
- C++ 报'vector' was not declared in this scope错误
- C++ - "'itoa' was not declared in this scope" 错误
- 错误:count was not declared in this scope
- 编译Android4.0.4常见错误 indexOfKey was not declared
- Error:'exit' was not declared !
- v4l2驱动摄像头 出现错误UINT64_C' was not declared in this scope 解决
- opencv 中的错误error: ‘SurfFeatureDetector’ was not declared in this scope
- BOOST ThreadPool 编译错误"TIME_UTC was not declared in this scope"
- 昨天的错误修改后,make出现error: 'UINT64_C' was not declared in this scope
- android NDK编译ffmpeg错误 'UINT64_C' was not declared in this scope的解决
- ndk编译错误:error: 'nullptr' was not declared in this scope
- 打包成jar文件后运行出现Invalid or corrupt jarfile 解决
- poj3617 贪心
- 广度优先搜索
- bower详细教程
- Server Tomcat v7.0 Server at localhost failed to start.
- 【C++标准I/0库】错误:runtime_error was not declared
- 算法之归并排序
- 【湖南集训 4.7】sanrd
- STL学习笔记— —容器forward_list
- 并查集——How Many Tables
- 在Androidstudio配置svn上找不到svn.exe解决方法
- 06_判断101-200之间有多少个素数,并输出所有素数
- 数据结构(9):二叉树的遍历、构建以及显示(凹入法)
- 算法_动态规划_矩阵路径最大和