How can we combine in this case two lists into one? If I make u2 = u; Then I will receive only a copy of the first list, but how else can I get the second list of u1? That is, the output I have to get the list: 1 2 3 3
class _List{ private: List* newList; public: _List() { newList = NULL; } void additem(int d); void additem2(); void Prints(); }; void _List::additem(int d){ List* createList = new List; createList -> da = d; createList -> next = NULL; List* x = new List; if (newList != NULL) { x = newList; while ((x->next) != NULL){ x = x->next; } x -> next = createList; }else{ newList = createList; } } void _List::Prints() { List* p = newList; cout <<"Spisok: ="; while (p){ cout<<p->da<<" "; p=p->next; } } int main(int argc, char* argv[]) { _List u; _List u1; _List u2; u.additem(1); u.additem(2); u.additem(3); u1.additem(3); u.Prints(); u1.Prints(); getch(); return 0; }
p->next = u2- pavel