【问题标题】:c++ passing by reference : error: no matching function for callc++ 通过引用传递:错误:没有匹配的调用函数
【发布时间】:2011-05-16 13:54:22
【问题描述】:

我有这个代码:

bool Port::add_app_from_wlist(App* a){
 stringstream namesurn;
 string name, surname;
 namesurn << a->get_name();
 namesurn >> name >> surname;
 return add_application(a->get_id(),name,surname,a->arrived_at_port_by(),a->arrived_by(),a->is_luxury_class());
}

我收到此错误:

air_classes.cpp:153: 错误:没有匹配的调用函数 到`Port::add_application(int, 标准::字符串&,标准::字符串&,时间_t, time_t, bool)'

air_classes.cpp:98: 注意:候选人是:bool 端口::add_application(int, 标准::字符串,标准::字符串,标准::字符串, time_t, time_t, bool)

我不明白这个 string& 在错误中来自哪里 - 我也不能修改它 - 请帮助。

【问题讨论】:

    标签: c++ string compiler-errors parameter-passing


    【解决方案1】:

    这些引用只是来自编译器,没有找到与您尝试传递的值匹配的合适的函数来调用,并猜测函数签名可能是什么样的。

    与列出的接受三个而不是两个字符串参数的候选进行比较。

    【讨论】:

      【解决方案2】:

      add_application 方法接受 3 个字符串,但您在调用中只指定了其中的 2 个。

      【讨论】:

      • 谢谢 - 好吧 - 我想我现在必须删除我的帐户 :ashamed:
      • @user:我记得自己多次犯过这样的错误(并且在没有人帮助的情况下无法找到问题所在):-) 两只眼睛肯定比一只眼睛好。跨度>
      猜你喜欢
      • 1970-01-01
      • 2016-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-10
      相关资源
      最近更新 更多