diff options
| author | Yana Blashchishina <[email protected]> | 2024-02-26 21:47:53 -0800 |
|---|---|---|
| committer | Yana Blashchishina <[email protected]> | 2024-02-26 21:47:53 -0800 |
| commit | d0e0ea7631626afafff1130154ae4dfa5691700d (patch) | |
| tree | 8bf88192b0e884d0de0884020123fd8fc9a7d5ff /Homework7 | |
| parent | forgot to commit, almost done (diff) | |
| download | homework-7-yanablash-main.tar.xz homework-7-yanablash-main.zip | |
Diffstat (limited to 'Homework7')
| -rw-r--r-- | Homework7/Homework7/ContactList.cpp | 37 | ||||
| -rw-r--r-- | Homework7/Homework7/ContactList.h | 10 |
2 files changed, 47 insertions, 0 deletions
diff --git a/Homework7/Homework7/ContactList.cpp b/Homework7/Homework7/ContactList.cpp index b934182..df6c849 100644 --- a/Homework7/Homework7/ContactList.cpp +++ b/Homework7/Homework7/ContactList.cpp @@ -1,4 +1,5 @@ #include "ContactList.h" +#include <atomic> @@ -67,3 +68,39 @@ Contact* ContactList::AllocateContactList(const size_t& size) return contacts; } + + +ContactList::ContactList(const Contact& copy) { + *this = copy; +} + + +ContactList& ContactList::operator=(const ContactList& rhs) { + if (this != &rhs) { + contacts_ = rhs.contacts_; + length_ = rhs.length_; + size_ = rhs.size_; + rhs.contacts_ = nullptr; + rhs.length_ = 0; + rhs.size_ = 0; + + } + return *this; +} + + +ContactList::ContactList(Contact&& move) { + *this = std::move(move); +} + +ContactList& ContactList::operator=(ContactList&& rhs) { + if (this != &rhs) { + contacts_ = rhs.contacts_; + length_ = rhs.length_; + size_ = rhs.size_; + rhs.contacts_ = nullptr; + rhs.length_ = 0; + rhs.size_ = 0; + } + return *this; +}
\ No newline at end of file diff --git a/Homework7/Homework7/ContactList.h b/Homework7/Homework7/ContactList.h index cf0b711..e449bc9 100644 --- a/Homework7/Homework7/ContactList.h +++ b/Homework7/Homework7/ContactList.h @@ -5,6 +5,16 @@ class ContactList { public: + + ContactList(const Contact& copy); + ContactList& operator=(const ContactList& rhs); + + ContactList& operator=(const Contact& rhs); + + + ContactList(Contact&& move); + ContactList& operator=(ContactList&& rhs); + ContactList() = default; ContactList(const size_t& size); ~ContactList(); |