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. MVC:上传文件

    今天写了一个使用MVC上传的DEMO,很简单不超过10行代码.代码如下(关注重点,所以尽量精简掉其他代码): 项目结构

  2. Objective C SEl 和@selector是怎么工作的||How do SEL and @selector work in iphone sdk?

    SEL is a type that represents a selector in Objective-C. The @selector() keyword returns a SEL that ...

  3. LPC1768之GPIO

    在AHB总线上以便IO的高速操作,上电默认为输入高电平,支持GPDMA操作. 1只有GPIO0和GPIO2上的引脚能产生中断,/EXIT0~3特殊的外中断引脚. 2P0.29/0.30很特殊要么同为输 ...

  4. php新浪微博登录接口用法实例

    本文实例讲述了php新浪微博登录接口用法.分享给大家供大家参考.具体分析如下: 在做微博登陆之前是需要申请到APP KEY 和App Secret,这个的申请方式请去 open.weibo.com 申 ...

  5. ubuntu安装mysql5.7

    sudo apt-get updatesudo apt-get upgradesudo apt-get install mysql-server mysql-client   #自动安装会装上5.7的 ...

  6. Python标准库的学习准备

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! Python标准库是Python强大的动力所在,我们已经在前文中有所介绍.由于标准 ...

  7. Java将一段逗号分割的字符串转换成一个数组

    String 类:String 类代表字符串.Java 程序中的所有字符串字面值都作为此类的实例实现.字符串是常量,它们的值在创建之后不能更改.字符串缓冲区支持可变的字符串.因为 String 对象是 ...

  8. Ubuntu下tftp服务搭建

    1.安装软件包 sudo apt-get install tftpd tftp xinetd 2.建立配置文件 在/etc/xinetd.d/下建立一个配置文件tftp sudo vi /etc/xi ...

  9. JAVA 中关于String的特性

    一.初始化String的两种方式 String str1 = "hello"; String str2 = new String("hello"); 第一种方式 ...

  10. Oracle逻辑读详解

    1.物理读(physical read) 当数据块第一次读取到,就会缓存到buffer cache 中,而第二次读取和修改该数据块时就在内存buffer cache 了 以下是例子: 1.1  第一次 ...