我有这个保存值的向量(不在堆上!)
std::vector<Dish> menu;
我想像这样实现复制赋值运算符:
Restaurant &Restaurant::operator=(Restaurant &&other) {
if (this == &other)
return *this;
open = other.open;
menu = std::move(other.menu);
}
我收到这些错误/警告:
^
/Users/avivlevitzky/CLionProjects/SPL-Project-1/Restaurant.cpp:49:10: note: in instantiation of member function 'std::__1::vector<Dish, std::__1::allocator<Dish> >::operator=' requested here
menu = other.menu;
^
/Users/avivlevitzky/CLionProjects/SPL-Project-1/Dish.h:18:15: note: copy assignment operator of 'Dish' is implicitly deleted because field 'id' is of const-qualified type 'const int'
const int id;
怎么了??