From 9f5eb77f6a8cba01158c37dc17e7e53574d87127 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 28 Apr 2022 19:10:39 +0300 Subject: Autocommit at 28.04.2022 @ 19:10 --- src/List/List.cpp | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'src/List/List.cpp') diff --git a/src/List/List.cpp b/src/List/List.cpp index a1892dd..1312e61 100644 --- a/src/List/List.cpp +++ b/src/List/List.cpp @@ -54,5 +54,47 @@ T& List::operator[](unsigned index) { template List::List() { - + length = 8; + count = 0; + elements = new T[length]; +} + +template +List& List::operator=(const List& other) { + if (this != &other) { + free(); + copyFrom(other); + } + return *this; +} + +template +List::List(const List& other) { + copyFrom(other); +} + +template +List::~List() { + free(); +} + +// Move semantics + +template +List::List(List&& other) { + length = other.length; + count = other.count; + elements = other.elements; + other.elements = nullptr; +} + +template +List& List::operator=(List&& other) { + if (this != other) { + length = other.length; + count = other.count; + elements = other.elements; + other.elements = nullptr; + } + return *this; } -- cgit v1.3.1-26-gb76a