Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/134.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
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; }_C++ - Fatal编程技术网

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; }

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; },c++,C++,我得到以下错误: 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

我得到以下错误:

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;

我不知道代码有什么问题,错误是什么意思?有人能帮忙吗。

const CLM&other
是一个r值参考。这些是C++ 11标准中对C++的新补充。将
-std=c++11
(或
-std=c++0x
如果您使用的是较旧的编译器,请查看文档)添加到编译器调用中。

const CLM&&other
是一个r值引用。这些是C++ 11标准中对C++的新补充。将
-std=c++11
(或
-std=c++0x
如果您使用的是较旧的编译器,请查看文档)添加到您的编译器调用中。

您使用的是
&
,它是一个。因此,您应该告诉编译器您正在使用
c++11
。在GCC中,您通过传递
-std=c++11
来实现这一点,您使用的是
&
,这是一个,它仅在
c++11
中有意义。因此,您应该告诉编译器您正在使用
c++11
。在GCC中,您通过传递
-std=c++11

来实现这一点,您的编译器似乎不支持c++11.1)您是在启用c++11支持的情况下编译的吗?2) 常量值引用是毫无意义的。不相关的:我必须承认,CLM的传统TLA让我笑了。如果你的“移动构造函数”只是要复制,你也可以省略它,让复制构造函数被选中,如果你的复制语义是复制每个成员,那么就同时省略这两个并使用默认生成的版本。你的编译器似乎不支持C++11.1)你是在启用C++11支持的情况下编译的吗?2) 常量值引用是毫无意义的。不相关的:我必须承认,CLM的传统TLA让我笑了。如果你的“移动构造函数”只是要复制,您也可以省略它,让复制构造函数被选择,如果复制语义是复制每个成员,那么就同时省略这两个成员,并使用默认生成的版本Accepted as answer,因为它首先被回答@Ivaylo Strandjev也感谢您的回答和您的参考链接。作为答案接受,因为它是第一个回答@Ivaylo Strandjev也感谢您的回答和参考链接。