I have a project due in 2 hours that I've been working on for weeks. I'm fairly confident that the project will work after I get help with this one function. I need to overload my assignment operator (=) so I can assign a returned Set to a newly created empty Set. I'm using linked lists and nodes containing one int value per node.
Heres my deconstructor:
Set::~Set()
{
while(head)
{
setNode *pTemp = head;
head = head->next;
delete pTemp;
}
}
My overloaded = operator function is this:
Set Set:perator = (const Set& S)
{
Set newSet(S);
if(this != &S)
~this;
for(setNode *p = S.head; p != NULL; p = p->next)
newSet += p->setVal; //+= adds the value to the set
return newSet;
}
I've tried it many different ways and although theres no syntax error, I keep getting memory overflow in my main before my while loop even reads once through. Maybe I'm not deconstructing something right? Any help is GREATLY appreciate. (Man had to type this post 3 times and 90% of the stuff in it, kept hitting escape after typing the code. Too used to vi in unix =(.