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. ADF_Starting系列4_使用ADF开发富Web应用程序之维护User Interface(Part1)

    2014-05-04 Created By BaoXinjian

  2. CF 191C Fools and Roads lca 或者 树链剖分

    They say that Berland has exactly two problems, fools and roads. Besides, Berland has n cities, popu ...

  3. Mongodb(1)如何存储以及简介

    在学习一个数据库之前应该了解这个数据库是如何存储的,是不是适合你所需要的存储方式. 如果上来就说命令,理解起来似乎有点麻烦. 不管学习什么数据库都应该学习其中的基础概念,在mongodb中基本的概念是 ...

  4. sax,Dom,等解析方式地址 ?

    Android中使用SAX对XMl文件进行解析 http://blog.csdn.net/developer_jiangqq/article/details/7197045 使用SAX技术对XML文档 ...

  5. 版本控制、SVN、VSS

    ylbtech-Miscellaneos: 版本控制.SVN.VSS 1.A,版本控制返回顶部 1, 版本控制(Revision control)是一种软体工程技巧,籍以在开发的过程中,确保由不同人所 ...

  6. 内联函数inline

    1:使用inline函数的时候,必须使函数体和inline说明结合一起,否则编译器将视他为普通函数处理: false: inline void Coord::setcoord(int a,int b) ...

  7. ruby中的reject和reject!

    reject和reject!reject返回不满足代码块的元素数组reject!删除数组中满足代码块的元素 a=[1,2,3,5]a.reject! {|x| x<4}p a #[5] b = ...

  8. [Flex] ButtonBar系列——最后一个项目的样式设置

    <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="ht ...

  9. nyoj 93 汉诺塔(三)

    点击打开链接 汉诺塔(三) 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述 在印度,有这么一个古老的传说:在世界中心贝拿勒斯(在印度北部)的圣庙里,一块黄铜板上插着三根宝 ...

  10. @Required @Autowired @Resource注解详解

    一.@Required注解用于检查特定的属性是否设置 1.RequiredAnnotationBeanPostProcessor 为该注解的处理器,即bean后置处理器,检查所有带有该解的bean属性 ...