Error no matching function for call to 'std::exception::exception(const char [15])'
Error no matching function for call to 'std::exception::exception(const char [15])'
Error 'logic_error' was not declared in this scope
错误原因
C++在使用VS 编译时抛出异常可以用下列语句:
throw std::exception("XXX");
但使用Dev-C++ (GCC) 编译时,会报以下错误:
Error no matching function for call to 'std::exception::exception(const char [15])'
解决方法:
#include <stdexcept>
throw std::logic_error("XXX");
如果不 #include <stdexcept> 则会报错:
Error 'logic_error' was not declared in this scope
附:
标准异常阶层体系


参考:
http://www.cplusplus.com/forum/beginner/107744/
https://blog.csdn.net/xiajun07061225/article/details/8231270
https://blog.csdn.net/fengbingchun/article/details/78303734
Error no matching function for call to 'std::exception::exception(const char [15])'的更多相关文章
- error: no matching function for call to 'std::exception:exception(const char[16])'
环境:codeblocks 语言:C++ 在执行:throw new exception("queue is empty.");时 遇到问题:error: no matching ...
- 【ERROR】no matching function for call to 'std::basic_ifstream<char>::basic_ifstream
错误记录:QT中使用 no matching function for call to 'std::basic_ifstream<char>::basic_ifstream(QString ...
- boost::bind 不能处理函数重载 (error: no matching function for call to 'bind')
前言 最近任务多.工期紧,没有时间更新博客,就水一期吧.虽然是水,也不能太失水准,刚好最近工作中遇到一个 boost::bind 的问题,花费了半天时间来定位解决,就说说它吧. 问题背景 项目中使用了 ...
- How to convert a std::string to const char* or char*?
How to convert a std::string to const char* or char*? 1. If you just want to pass a std::string to a ...
- std::string stringf(const char* format, ...)
std::string stringf(const char* format, ...){ va_list arg_list; va_start(arg_list, format); // SUSv2 ...
- Qt error ------ no matching function for call to QObject::connect(QSpinBox*&, <unresolved overloaded function type>, QSlider*&, void (QAbstractSlider::*)(int))
connect(ui->spinBox_luminosity,&QSpinBox::valueChanged, ui->horizontalSlider_luminosity, & ...
- no matching function for call to ‘std::basic_string<char>::assign(std::string&, int)
使用string中的assign赋值函数报错,代码为: text0.assign(line,i+); 其中text0与line都为string类型 最后发现assign函数的原型为 string &a ...
- error: no matching function for call to 'Ui::GoToCellDialog::setupUi(QDialog*&)' ui.setupUi(dialog); ^
环境:Qt5.3 参考书是:C++ GUI Qt4编程 问题描述: 按照书中的例子2-2做,编译时遇到的问题,从字面意思看是没有匹配的函数可用,UI::GotoCellDialog类是自动生成的,所以 ...
- g2o相关问题cs.h,以及no matching function for call to ‘g2o::OptimizationAlgorithmLevenberg::OptimizationAlgorithmLevenberg(Block*&)
1.对于cs.h找不到的情况 1)编译的时候一定要把csparse在EXTERNAL文件中,编译进去. 2)修改CMakeLists.txt文件中的include_directories中的${CPA ...
随机推荐
- CSS中的BFC详解
引言: 这篇文章是我对BFC的理解及总结,带你揭开BFC的面纱.你将会知道BFC是什么,形成BFC的条件,BFC的相关特性,以及他的实际应用. 一.何为BFC BFC(Block Formatting ...
- POJ 1260
//状态转移方程: F[i] = min{f[k] + (a[k+1]+………+a[i]+10} * p[i]} #include <iostream> #define MAXN 105 ...
- bootstrap-validator
使用bootstrap-validator挺多的,虽然自己写认证并不复杂,我一向喜欢现成的控件,原因是风格一致,不容易出错. 这个是接口文档:http://bv.doc.javake.cn/setti ...
- (转)MySQL的Grant命令
[MySQL] - MySQL的Grant命令 来源:http://yingxiong.javaeye.com/blog/451208 本文实例,运行于 MySQL 5.0 及以上版本. MySQL ...
- java android中日期时间 问题总结
Date 类型: Date date = new Date(); // 代表获取当前系统日期和时间 System.out.println(date); 使用类的方法设置时间和日期:(通过该方法初始 ...
- java数据结构之二叉树遍历的非递归实现
算法概述递归算法简洁明了.可读性好,但与非递归算法相比要消耗更多的时间和存储空间.为提高效率,我们可采用一种非递归的二叉树遍历算法.非递归的实现要借助栈来实现,因为堆栈的先进后出的结构和递归很相似.对 ...
- free -m内存使用详解
第一部分Mem这行:total -> 内存总数: 32014M=32Gused -> 已经使用的内存数: 7665Mfree -> 空闲的内存数: 24349Mshared -> ...
- tar 命令压缩时报错 tar: Removing leading `/' from member names
在使用tar命令进行压缩打包的时候我们常常会遇到下面的错误.虽然它不会影响我们最后的压缩打包,但是间接说明了我们的命令是有问题的.接下来我们来看看解决的方法. 报错内容: [root@haha ~]# ...
- 02-python基本数据类型
python的变量不需要声明, 但变量使用前必须复制, 因为python中所有的内容全部是对象 变量是没有类型的, 有类型的是指向内存对象的类型 a = ' a = 是合法的 此外, python还可 ...
- double类型转换为int类型四舍五入工具类
package com.qiyuan.util; import java.math.BigDecimal; import java.text.DecimalFormat; public class G ...