2010-11-27 96 views
1

我有这样的代码:C++引用传递:错误:没有匹配函数调用

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: error: no matching function for call to `Port::add_application(int, std::string&, std::string&, time_t, time_t, bool)'

air_classes.cpp:98: note: candidates are: bool Port::add_application(int, std::string, std::string, std::string, time_t, time_t, bool)

我不明白,在此字符串&来自于错误 - 我怎么能修改它 - 请帮助。

回答

7

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

+0

感谢-well--我想我现在必须删除我的帐户:惭愧: – 2010-11-27 21:19:56

+0

@user:我记得自己多次犯这样的错误(并且没有人的帮助无法找到问题所在):-) Two一双眼睛肯定比一只眼睛好。 – Vlad 2010-11-27 22:50:50

3

引用只是来自编译器没有找到合适的函数来调用,它与您正在尝试传递的值相匹配,并猜测函数签名可能看起来像什么。

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

相关问题