diff --git a/Foundation_Classes/List.cpp b/Foundation_Classes/List.cpp index 9c4f648..5b52f90 100644 --- a/Foundation_Classes/List.cpp +++ b/Foundation_Classes/List.cpp @@ -30,8 +30,25 @@ List::~List() { delete[] _items; } -// TODO: operator= - +// Implements the assignment operation to assign member data properly. +template +List& List::operator=(const List& other) { + if (this != &other) { // Check for self-assignment + // Clear the current list + RemoveAll(); + + // Allocate memory for the new list + _size = other._size; + _count = other._count; + _items = new Item[_size]; + + // Copy elements from the other list to this list + for (long i = 0; i < _count; ++i) { + _items[i] = other._items[i]; + } + } + return *this; +} template long List::Count() const {