Rename directories, fix assignment operator in singlelist

This commit is contained in:
Shaun Reed 2020-04-26 21:47:59 -04:00
parent 255ba5a291
commit 110ac83be8
4 changed files with 6 additions and 5 deletions

View File

@ -19,7 +19,7 @@ int main()
{
std::cout << "Driver: \n";
SingleList testList;
SingleList testList, test;
bool exit = false;
int choice = -1;
int val, key;
@ -41,6 +41,7 @@ int main()
std::cin >> val;
std::cin.clear();
testList.insert(val);
test = testList;
break;
case INSERTAT:
@ -67,6 +68,7 @@ int main()
case PRINT:
testList.print();
test.print();
break;
case FIND:

View File

@ -42,11 +42,10 @@ SingleList::SingleList(const SingleList& rhs)
* @param rhs SingleList object
* @return SingleList& A shallow copy of the rhs SingleList in the assignment
*/
SingleList SingleList::operator=(SingleList& rhs)
SingleList SingleList::operator=(SingleList rhs)
{
if (this == &rhs) return *this;
else head = rhs.head;
std::swap(head, rhs.head);
return *this;
}

View File

@ -22,7 +22,7 @@ class SingleList{
public:
SingleList() : head(NULL) {};
SingleList(const SingleList& rhs);
SingleList operator=(SingleList& rhs);
SingleList operator=(SingleList rhs);
~SingleList();
bool insert(int val);
bool insert(int val, int key);