C++异常:no matching function for call to "Matrix(Matrix&)"

我定义了一个类叫Matrix,其中构造函数explicit Matrix(const Matrix& source);

也写了一个方法:

Matrix Matrix::myFun(const Matrix &source)
{
  ...

return *this;
}

编译报出上面的异常来,原因是explicit关键字抑制隐式转换,当我返回*this的时候相当于:Matrix myMatrix = *this,由于禁止隐式转换,所以这个是报错的。

当我删掉explicit关键字后,发生了隐式转换:Matrix tmp(*this),然后调用编译器提供的默认复制构造函数Matrix myMatrix(tmp)。则顺利通过编译。

C++异常:no matching function for call to "Matrix(Matrix&)"的更多相关文章

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

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

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

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

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

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

  6. no matching function for call to 'make_pair(std::string&, size_t&)'

    rtl->push_back(make_pair<string, int>(str, pos)); 在redhat6上编译无问题,在centos7上编译出现错误: no matchi ...

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

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

  8. no matching function transform?

    http://stackoverflow.com/questions/19876746/stdtolower-and-visual-studio-2013 http://forums.codeguru ...

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

随机推荐

  1. (C# Debug)A first chance exception of type 'System.ArgumentException' occurred in System.Data.dll

    Debug 模式下运行程序的时候,Output 窗口出来个错误“A first chance exception of type 'System.ArgumentException' occurred ...

  2. BIP_开发案例04_通过BI Publisher实现打印报表的二维码(案例)(待整理)

    2014-01-01 Created BaoXinjian

  3. OAF_EO系列4 - Create详解和实现(案例)

    2014-06-02 Created By BaoXinjian

  4. 树莓派3上安装Qt5

    按照在2上的安装只安装了qt4,实际上qt5已经可以直接apt方式可以获取到树莓派上了. install qt5-default and qtcreator:$ sudo apt-get instal ...

  5. c#生成缩略图

    publicstaticvoidGenThumbnail(Image imageFrom,stringpathImageTo,intwidth,intheight)         {         ...

  6. Decorator装饰模式

    动态地给一个对象增加一些额外的职责.就增加功能而言,Decorator模式比生成子类更为灵活. ——<设计模式>GoF 作用:在不影响其他对象的情况下,以动态.透明的方式给单个对象添加职责 ...

  7. centos5安装在大硬盘上面的问题

    硬盘空间大小: 3TB 原始硬盘是GPT格式的,系统安装现象如下: 此时按 ctrl + alt + F2 ,进入命令行界面,输入如下: 发现 用parted修改硬盘分区格式为msdos,报错!基本可 ...

  8. Java中数字操作

    public static void main(String[] args) throws Exception { { //Math函数的四舍五入,注意负数的时候小数位<=0.5都会被舍去,&g ...

  9. jQuery的jsonp跨域是这么回事.

    实现跨域请求的有iframe,img,script中的src属性.那么jquery是如何解决跨域请求的呢? 一:项目jsonp2中有个app.js文件,代码如下: function app(json) ...

  10. Ext 4.2 RowEditing

    Follow: function () { Ext.define('Follow', { extend: 'Ext.data.Model', idProperty: 'id', fields: [ { ...