I am implemented a class for Weighting scheme and have created 4 constructor in the class with different number of parameters.when i try to invoke the constructor with parameter of a particular constructor then also the default constructor with no parameters is called.I am unable to understand why such this is happening .
Definition of constructor:
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 {
Calling of constructor:
79 enquire.set_weighting_scheme(Xapian::UnigramLMWeight(double(322.0),int(2),double(2000.0),double(2.0)));
But i have checked the values which are set are from default constructor.
can any one help me why this default constructor is called or is it every time default constructor is called after parametric constructor or the parameters are casted to some other type and constructor try to find such constructor but is unable to find such constructor and calls default constructor finally.
Code of set_weigthing scheme is :
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 }
Do the set_weighing scheme set method calls clone function,do this is root couse of problem when it clones default constructor is called,is it so ?
Can that be reason ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…