Как можно объединить в данном случае два списка в один? Если я сделаю u2=u; То я получу только копию первого списка, а как еще получить второй список u1? То есть на выходе я должен получить список: 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 -> d.a = 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->d.a<<" ";
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