Hi I have this error in the main.cpp with my operator= and I don't know what's the problem with it. Or maybe the problem is from the functions... I don't know. If you could help me it will be great! Thank you!
my main.cpp:
#include <iostream>
#include "List.h"
using namespace std;
List merge(List &lst1, List &lst2);
void makeSet(List lst);
int main()
{
List lst1, lst2, mergedList;
cout<<"enter sorted values for the first list:"<< endl;
cin>>lst1;
cout<<"enter sorted values for the second list:"<< endl;
cin>>lst2;
mergedList = merge(lst1,lst2); //My ERROR is here (No viable overloaded '=')
cout <<"the new merged list: " << mergedList <<endl;
makeSet(mergedList);
cout<<"the new merged set: " << mergedList << endl;
return 0;
}
my operator= (in List.cpp):
List& List::operator=(List& l){
l.clear();
Link *src, *trg;
head = new Link(l.head->value, NULL);
src = l.head;
trg = head;
while(src->next!=NULL)
{
//create new Link, and attach to end of new list
trg->next = new Link((src->next)->value, NULL);
src = src->next;
trg = trg->next;
}
return *this;
}
my operator in the header:
List& operator=(List&);