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])'的更多相关文章

  1. error: no matching function for call to 'std::exception:exception(const char[16])'

    环境:codeblocks 语言:C++ 在执行:throw new exception("queue is empty.");时 遇到问题:error: no matching ...

  2. 【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 ...

  3. boost::bind 不能处理函数重载 (error: no matching function for call to 'bind')

    前言 最近任务多.工期紧,没有时间更新博客,就水一期吧.虽然是水,也不能太失水准,刚好最近工作中遇到一个 boost::bind 的问题,花费了半天时间来定位解决,就说说它吧. 问题背景 项目中使用了 ...

  4. 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 ...

  5. std::string stringf(const char* format, ...)

    std::string stringf(const char* format, ...){ va_list arg_list; va_start(arg_list, format); // SUSv2 ...

  6. 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, & ...

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

  8. error: no matching function for call to 'Ui::GoToCellDialog::setupUi(QDialog*&)' ui.setupUi(dialog); ^

    环境:Qt5.3 参考书是:C++ GUI Qt4编程 问题描述: 按照书中的例子2-2做,编译时遇到的问题,从字面意思看是没有匹配的函数可用,UI::GotoCellDialog类是自动生成的,所以 ...

  9. 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 ...

随机推荐

  1. leetcode-179-Largest Number(理解规则,自定义cmp函数进行排序)

    题目描述: 给定一组非负整数,重新排列它们的顺序使之组成一个最大的整数. 示例 1: 输入: [10,2] 输出: 210 示例 2: 输入: [3,30,34,5,9] 输出: 9534330 说明 ...

  2. Swift 4.0 废弃的柯里化

    // 柯里化 // http://www.jianshu.com/p/6eaacadafa1a                               Swift 2.0 柯里化方法 (废弃) / ...

  3. Mime、base64编码

    第一部分 在阮一峰老师的博客中,是这样介绍Mime的: MIME的全称是"Multipurpose Internet Mail Extensions",中译为"多用途互联 ...

  4. 转载 linux umount 时出现device is busy 的处理方法--fuser

    http://www.cnblogs.com/spicy/p/6894333.html (原文链接) 当任何目录有 mount, 然后有程序使用/挂在那个目录上的话, 就没有办法 umount 掉, ...

  5. Android 开发工具类 16_NotificationActivity

    在前台运行的 Activity 可以通过Dialog.Toast 向用户发出提示信息,而后台运行的程序,如下载.收到信息等 Service 应用,则需要使用 Notification(通知)向用户发出 ...

  6. AttrContext

    info属性类型为AttrContext或AttrContextEnv.主要看AtrContext即可.定义了如下关键参数: /** Contains information specific to ...

  7. Glide的用法

    最基本用法 glide采用的都是流接口方式 简单的从网络加载图片 Glide.with(context).load(internetUrl).into(targetImageView); 从文件加载 ...

  8. 11 - JavaSE之GUI

    GUI(念法 gu yi) AWT AWT(Abstract Window Toolkit 抽象窗口开发包,在C# 或者 linux窗口开发类之上又封装一层,达到跨平台的目的)包括了很多类和接口,用于 ...

  9. ActiveMQ HelloWorld入门

    在P2P的消息模型中,双方通过队列交流,一个队列只有一个生产者和一个消费者.a.消息生产者 package com.ljq.durian.test.activemq; import javax.jms ...

  10. Web服务(Apache、Nginx、Tomcat、Jetty)与应用(LAMP、CMS-WordPress&Ghost、Jenkins、Gitlab)

    Web服务和应用是目前信息技术领域的热门技术.如何使用Docker来运行常见的Web服务器(包括Apache.Nginx.Tomcat等),以及一些常用应用(LAMP.CMS等).包括具体的镜像构建方 ...