/**** definicja klasy lista jednokierunkowa ****/
// od paranoika - wstawiłem w tagi 'code' bo się rozjeżdżało.
#include <iostream>using namespace std;class lista {public:struct node{ node * next; double obj; node(): next(NULL) {}; ~node() { while(next) { node * wsk_next = next->next; // 1 next->next = NULL; // 2 delete (next); // 3 next = wsk_next; // 4 } }};private: node * first;public:lista() : first(NULL) {}~lista() {}lista(const lista & wzor){ node * spointer; node * pointer; pointer = first = NULL; spointer = wzor.first; while(spointer) { node * temp = new node; temp -> obj = spointer ->obj; if(first == NULL) { first = temp; pointer = temp; } else { pointer ->next = temp; pointer = temp; } spointer = spointer -> next; } }lista & operator= (const lista& wzor){ delete (first); node * spointer; node * pointer; pointer = first = NULL; spointer = wzor.first; while(spointer) { node * temp = new node; temp -> obj = spointer ->obj; if(first == NULL) { first = temp; pointer = temp; } else { pointer ->next = temp; pointer = temp; } spointer = spointer -> next; } return *this;}bool findelem(double value , node ** prev , node ** curr){ *prev = NULL; *curr = first; while( *curr != NULL) { if( (*curr) -> obj == value) return true; *prev = *curr; *curr = (*curr) ->next; } return false;}void insert(double wstawka){ node * prev; node * curr; if(!findelem(wstawka , &prev , &curr)) { node * temp = new node; temp -> next = first; first = temp; temp -> obj = wstawka; }}bool erase(double wartosc){ node * prev; node * curr; bool jest = findelem(wartosc,&prev , &curr); if(jest) { node * temp; temp = curr -> next; curr -> next = NULL; delete curr; if (prev) prev ->next = temp; else first = temp; } return jest;}void dump(){ node * pokazywacz = first; while(pokazywacz) { cout << pokazywacz ->obj << endl; pokazywacz = pokazywacz ->next; }}}; /**** koniec definicji klasy lista jednokierunkowa ****/ int main(){ lista ld; ld.insert(1.001); ld.insert(2.002); ld.insert(3.003); ld.insert(4.004); ld.insert(5.005); lista ld2 = ld; ld.erase(3.003); ld.erase(2.002); ld.erase(1.001); ld.dump(); ld2.dump(); ld = ld2; ld.dump(); return 0;}to jest lista jednokieunkowa i takie same funkcje ma posiadac cykliczna;