简体   繁体   English

解密函数未找到错误消息

[英]Deciphering a function overload not found error message

I have the following code :- 我有以下代码:

class A : public B {
  public:
    _container (B* b) { 
      container_ = b;
    }
  private:
    B* container_;
};

void foo(const A& a, const B& b) {
  A new_a (a);
  new_a._container(&b);
}

If I try to compile this using icpc12, I get :- 如果我尝试使用icpc12进行编译,则会得到:-

error: no instance of overloaded function "A::_container" matches the argument list
            argument types are: (const B *)
            object type is: A
      new_a._container (&b);

Now, I understand that the first line of the error means there is some sort of type mismatch between the function being called and the function definitions available and I'm trying to narrow down the problem using the other two lines of the error message. 现在,我知道错误的第一行表示被调用的函数与可用的函数定义之间存在某种类型的不匹配,并且我正在尝试使用错误消息的其他两行来缩小问题的范围。

What do the second and third lines mean? 第二和第三行是什么意思?

该函数将非const指针作为参数,并且您正在传递const指针。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM