我爲加權方案實現了一個類,並在類中創建了4個具有不同數量參數的構造函數。當我嘗試使用特定構造函數的參數調用構造函數時,沒有參數被調用。我無法理解爲什麼會發生這種情況。構造函數的默認的構造函數,而不是參數化的構造函數
定義:
593 UnigramLMWeight(double param_log_,int select_smoothing_,double param_smoothing1_,double param_smoothing2_)
594 : select_smoothing(select_smoothing_), param_log(param_log_), param_smoothing1(param_smoothing1_),
595 param_smoothing2(param_smoothing2_)
596 {
構造的呼喚:
79 enquire.set_weighting_scheme(Xapian::UnigramLMWeight(double(322.0),int(2),double(2000.0),double(2.0)));
但我已經檢查其設置的值從默認的構造函數。
任何人都可以幫助我爲什麼這個默認的構造函數被調用,或者是每次默認的構造函數被調用後參數構造函數或參數被轉移到其他類型和構造函數嘗試找到這樣的構造函數,但無法找到這樣的構造函數並最終調用默認的構造函數。
set_weigthing方案的準則是:
926 Enquire::set_weighting_scheme(const Weight &weight_)
927 {
928 LOGCALL_VOID(API, "Xapian::Enquire::set_weighting_scheme", weight_);
929 // Clone first in case doing so throws an exception.
930 Weight * wt = weight_.clone();
931 swap(wt, internal->weight);
932 delete wt;
933 }
執行set_weighing方案集合方法調用克隆功能,做到這一點是問題的根本職高當克隆默認構造函數被調用,是這樣嗎? 這是理由嗎?
HM,你想用什麼語言用的? C#,C++和C是相當不同的。它不能是C(因爲你正在說對象),'''在'正常'的C#代碼中很少見......我懷疑你想要C++,但是你的標籤很難告訴 – Crisfole
請提供一個完整的,最小的示例程序來演示問題。 –
@ChristopherPfohl其C++抱歉,更正了標籤...對不起,最初添加這些標籤 – samuelhard