C++ Adding Linked Lists

ravana

Platinum Member
Jul 18, 2002
2,149
1
76
Ok I have written a program for class in C++ to add two linked lists overloading the + & += operatorss.

But the method that was explained to me was such that when I add two lists
for example
List1 and List2, results in List1+=List2 & List3=List1+List2

What happens in these cases is that the original lists get destroyed(as in the original lists are empty).

It is not a requirement for the assignment that the lists not be destroyed, I was just curious so I did a little search on the net and I did not find anything relevant. I was just wondering if anyone on here knew anything how to do it.

Thanks in advance.

Ravana.
 

Shalmanese

Platinum Member
Sep 29, 2000
2,157
0
0
Can't you just change the tail pointer of list1 to be the head pointer of list 2 and make the head pointer of list 3 the same as the head pointer of list 1?

I assume that is what you want.