diff options
| author | Syndamia <kamen@syndamia.com> | 2024-05-08 10:07:57 +0300 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2024-05-08 10:07:57 +0300 |
| commit | 75cff007b4896eed49b758be0959668673ae1bf3 (patch) | |
| tree | 6af017d6047c78bce05af166fdbe85cae40692b5 /week10/Exercise08/Administrator.cpp | |
| parent | 6dd52a7c9d8db3e8b14494ae99e8b9f3b76d1262 (diff) | |
| download | oop-2023-solutions-75cff007b4896eed49b758be0959668673ae1bf3.tar oop-2023-solutions-75cff007b4896eed49b758be0959668673ae1bf3.tar.gz oop-2023-solutions-75cff007b4896eed49b758be0959668673ae1bf3.zip | |
[w10] Fixed mistakes in certain exercises
Diffstat (limited to 'week10/Exercise08/Administrator.cpp')
| -rw-r--r-- | week10/Exercise08/Administrator.cpp | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/week10/Exercise08/Administrator.cpp b/week10/Exercise08/Administrator.cpp index aaeecf8..23d9659 100644 --- a/week10/Exercise08/Administrator.cpp +++ b/week10/Exercise08/Administrator.cpp @@ -1,4 +1,5 @@ #include "Administrator.h" +#include <iostream> void Administrator::resize() { allocated *= 2; @@ -11,16 +12,14 @@ void Administrator::resize() { } void Administrator::free() { - Moderator::free(); delete[] arr; } void Administrator::copyFrom(const Administrator& other) { - Moderator::copyFrom(other); this->arr = new int[other.allocated]; for (int i = 0; i < other.size; i++) { this->arr[i] = other.arr[i]; -} + } } Administrator::Administrator() : Moderator() { @@ -29,28 +28,23 @@ Administrator::Administrator() : Moderator() { } Administrator::~Administrator() { - Administrator::free(); + free(); } -Administrator::Administrator(const Administrator& other) { - Administrator::copyFrom(other); +Administrator::Administrator(const Administrator& other) : Moderator(other) { + copyFrom(other); } Administrator& Administrator::operator=(const Administrator& other) { if (this != &other) { - Administrator::free(); - Administrator::copyFrom(other); + Moderator::operator=(other); + free(); + copyFrom(other); } return *this; } -Administrator::Administrator(Administrator&& other) { - this->name = other.name; - other.name = nullptr; - this->password = other.password; - other.password = nullptr; - this->signature = other.signature; - other.signature = nullptr; +Administrator::Administrator(Administrator&& other) : Moderator(other) { this->arr = other.arr; other.arr = nullptr; this->size = other.size; @@ -59,14 +53,9 @@ Administrator::Administrator(Administrator&& other) { Administrator& Administrator::operator=(Administrator&& other) { if (this != &other) { - Administrator::free(); + free(); + Moderator::operator=(std::move(other)); - this->name = other.name; - other.name = nullptr; - this->password = other.password; - other.password = nullptr; - this->signature = other.signature; - other.signature = nullptr; this->arr = other.arr; other.arr = nullptr; this->size = other.size; |
