Ok, I've got a copy constructor for a class. I'm not gonig to post it here, because it works fine. However, when tryingto overload the = operator, it doesn't work so well.
WumpusList WumpusList:
perator=(WumpusList w){
WumpusList newlist = w;
cout << "list passed to =:\n";
w.PrintList();
cout << "end list\n";
cout << "list returned by =\n";
newlist.PrintList();
cout << "end list\n";
return newlist;
}
when the lists are printed, theyboth show as equal. however if I call this fuction like:
WumpusList list1;
WumpusList list2;
// stuff to fill list1 here
list2 = list1; // this line returns NOTHING.
What am I doing wrong?
this:
WumpusList list1;
// stuff to fill list1 here
WumpusList list2 = List1;
works fine
Help?
WumpusList WumpusList:
WumpusList newlist = w;
cout << "list passed to =:\n";
w.PrintList();
cout << "end list\n";
cout << "list returned by =\n";
newlist.PrintList();
cout << "end list\n";
return newlist;
}
when the lists are printed, theyboth show as equal. however if I call this fuction like:
WumpusList list1;
WumpusList list2;
// stuff to fill list1 here
list2 = list1; // this line returns NOTHING.
What am I doing wrong?
this:
WumpusList list1;
// stuff to fill list1 here
WumpusList list2 = List1;
works fine
Help?