我不知道我在做什麼錯,但我有推功能的問題。你可以幫幫我嗎?單鏈表推功能錯誤
#include<iostream>
#include<memory>
using namespace std;
struct lista {
int value;
unique_ptr<lista>next;
lista(int value):value(value), next(nullptr){}
};
void push(int x, unique_ptr<lista> &h) {
unique_ptr<lista>alok_pam_x = make_unique<lista>(x);
if (alok_pam_x!= nullptr)
{
(alok_pam_x->next) = h;
h = alok_pam_x;
}
}
和我有錯誤:
Severity Code Description Project File Line Suppression State Error C2280 'std::unique_ptr> &std::unique_ptr<_Ty,std::default_delete<_Ty>>::operator =(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)': attempting to reference a deleted function
Severity Code Description Project File Line Suppression State Error (active) function "std::unique_ptr<_Ty, _Dx>::operator=(const std::unique_ptr<_Ty, _Dx>::_Myt &) [with _Ty=lista, _Dx=std::default_delete]" (declared at line 1436 of "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory") cannot be referenced -- it is a deleted function