移动构造函数的奇怪编译错误

Strange compilation error for a move constructor

本文关键字:编译 错误 构造函数 移动      更新时间:2023-10-16

我正在尝试制作移动构造函数,但出现错误

expected ',' or '...' before '&&' token

这是导致问题的行:

List(List&& list) noexcept;

我还有一个看起来相似的复制构造函数。不知道这是否会引起麻烦:

List(const List& copy);

(这一切都在我的 List 类的头文件中)

确保使用可以编译 C++11 代码的编译器(并设置为这样做),这在以前版本的 C++ 标准中无效