我想编译一个C++代码,下面是代码片段,我在该代码片段下面添加了错误。C++中无效的构造函数错误
// Move constructor
CLM(const CLM&& other)
{
this->detection_success = other.detection_success;
this->tracking_initialised = other.tracking_initialised;
this->detection_certainty = other.detection_certainty;
this->model_likelihood = other.model_likelihood;
this->failures_in_a_row = other.failures_in_a_row;
pdm = other.pdm;
params_local = other.params_local;
params_global = other.params_global;
detected_landmarks = other.detected_landmarks;
landmark_likelihoods = other.landmark_likelihoods;
patch_experts = other.patch_experts;
landmark_validator = other.landmark_validator;
triangulations = other.triangulations;
kde_resp_precalc = other.kde_resp_precalc;
}
// Assignment operator for rvalues
CLM & operator= (const CLM&& other)
{
this->detection_success = other.detection_success;
this->tracking_initialised = other.tracking_initialised;
this->detection_certainty = other.detection_certainty;
this->model_likelihood = other.model_likelihood;
this->failures_in_a_row = other.failures_in_a_row;
pdm = other.pdm;
params_local = other.params_local;
params_global = other.params_global;
detected_landmarks = other.detected_landmarks;
landmark_likelihoods = other.landmark_likelihoods;
patch_experts = other.patch_experts;
landmark_validator = other.landmark_validator;
triangulations = other.triangulations;
kde_resp_precalc = other.kde_resp_precalc;
return *this;
}
我得到下面的错误:
In file included from ../../Demo/Pack/CLM/include/CLM_utils.h:9:0,
from ../../Demo/Pack/CLM/src/CCNF_patch_expert.cpp:3:
../../Demo/Pack/CLM/include/CLM.h:170:16: error: expected ‘,’ or ‘...’ before ‘&&’ token
CLM(const CLM&& other)
^
../../Demo/Pack/CLM/include/CLM.h:170:24: error: invalid constructor; you probably meant ‘CLMTracker::CLM (const CLMTracker::CLM&)’
CLM(const CLM&& other)
^
../../Demo/Pack/CLM/include/CLM.h:192:28: error: expected ‘,’ or ‘...’ before ‘&&’ token
CLM & operator= (const CLM&& other)
^
../../Demo/Pack/CLM/include/CLM.h: In member function ‘CLMTracker::CLM& CLMTracker::CLM::operator=(CLMTracker::CLM)’:
../../Demo/Pack/CLM/include/CLM.h:194:29: error: ‘other’ was not declared in this scope
this->detection_success = other.detection_success;
我不知道什么是错的代码,意味着什么错误?有人可以帮忙吗?
似乎你的编译器不支持C++ 11。 – 2014-09-11 11:15:35
1)您是否在启用C++ 11支持的情况下进行编译? 2)const的右值引用是毫无意义的。 – 2014-09-11 11:15:55
无关:CLM的传统TLA让我微笑,我必须承认。 – WhozCraig 2014-09-11 11:16:40