Well, in your code (which I don't have in front of me) you do something like this:
Code:
linklist listA;
linklist listQ;
// ...
listQ = listA;
The last line is the same as:
Code:
listQ.operator=(listA);
Now, listA is a variable of type linklist. When passing it to a method, the argument to the method can be linklist, linklist&, const linklist&, or any other type that can be implicitly converted to from your linklist (I don't think you have any of those so don't worry about that one). So if you pass listA as an argument to a method, that method better take one of those three things as a parameter.
You couldn't call a function like this:
Code:
void Foo1(int i) { cout << i << endl; }
int main()
{
int* pi = new int(2);
Foo(pi); // ERROR - Type mismatch, function takes int not int*.
}
But you of course could do this:
Code:
void Foo1(int i) { cout << i << endl; }
void Foo2(int& i) { cout << i << endl; }
void Foo3(const int& i) { cout << i << endl; }
int main()
{
int myI = 2;
Foo1(myI); // Fine.
Foo2(myI); // Fine.
Foo3(myI); // Fine.
}
The same goes for your operator= function inside your linklist class. If you wanted to be crafty, you could probably set something up so that you could pass in a pointer, but that would be stupid because it is easy to use the reference and it is the standard way of doing operator= and the copy constructor. Don't try and do it some crazy way because there is a reason people don't implement those functions with pointer parameters.
The reason this causes problems in your program is because your pointer versions of this function are never called. The compiler looks for an operator= function that takes one of the three parameter types I mentioned above and can't find one, so it uses the default operator= which copies the pointers and not the data, eventually leading to your problems inside the destructor.
So take the function prototypes I gave in my last post and figure out how to fix the compile errors. It really shouldn't be very hard. Like I said then, pretty much all you have to do is use '.' instead of '->' when referring to the list that is passed in (the source list).