operacja pop lista jednokierunkowa

0

Nie rozumiem dlaczgo mam błąd operacji pop

 #include<iostream>
#include<memory>
#include<string>
#include<stdio.h>
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);
		(alok_pam_x->next) =move(h);
		h=move(alok_pam_x);
}
void druklista(unique_ptr<lista>&h)
{
	lista*p=h.get();
	cout << "{";
	while (p != nullptr)
	{
		cout << p->value;
		p = p->next.get();
		if(p != nullptr)
			cout<<",";
	}
	cout << "}"<<endl;
}
void druklista2(lista *h)
{
	printf("{");
	while (h != NULL)
	{
		printf("%d", h->value);
		h=h->next.get();
		if (h != NULL) printf(",");
	}
	printf("}\n");
}

ostream& operator << (ostream& stream, lista* h) {
	if (h) {
		stream << h->value <<" "<<h->next.get();
	}
	return stream;
}

void konstrlista(int n, int z, unique_ptr<lista>&h) {
	int i, x;
	h = nullptr;
	for (i = 0; i < n; ++i)
	{
		x = rand() % z;
		push(x, h);
	}
}//konstrlista

void pop(unique_ptr<lista>&h, unique_ptr<int>& x) {
	unique_ptr<lista>p;
	if (h != nullptr) {
		*x = h->value; p =move(h); h = move(h->next);
		p->next = nullptr;
	}
}//pop O(1)


int main() {
	unique_ptr<lista> list;
	
	konstrlista(10, 20, list);
	cout << list.get();
	cout << endl << list.get();
	unique_ptr<int>x = (new int);
	pop(list, x);

}

1 użytkowników online, w tym zalogowanych: 0, gości: 1