2010-11-27 122 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

引用只是來自編譯器沒有找到合適的函數來調用,它與您正在嘗試傳遞的值相匹配,並猜測函數簽名可能看起來像什麼。

與接受三個而不是兩個字符串參數的候選列表進行比較。

相關問題