简体   繁体   中英

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

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指针。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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