diff options
| author | Asahel <[email protected]> | 2024-03-08 09:49:58 -0800 |
|---|---|---|
| committer | Asahel <[email protected]> | 2024-03-08 09:49:58 -0800 |
| commit | 341872c09593f41cbe27326d9462d4f7d7668ebd (patch) | |
| tree | 8c42ec86c4653661e819805bf5dd5c365ef6c28d /InclassExercise14/Contact.cpp | |
| parent | Implemented copy and move constructor (diff) | |
| download | in-class-exercise-14-asahellt-main.tar.xz in-class-exercise-14-asahellt-main.zip | |
Diffstat (limited to 'InclassExercise14/Contact.cpp')
| -rw-r--r-- | InclassExercise14/Contact.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/InclassExercise14/Contact.cpp b/InclassExercise14/Contact.cpp index fadde86..13f1183 100644 --- a/InclassExercise14/Contact.cpp +++ b/InclassExercise14/Contact.cpp @@ -9,6 +9,31 @@ class Contact { int zip{}; char* _email{}; +public: + + Contact(const Contact& other) { + firstName = new + char[strlen(other._firstName) + 1] + + _lastName = new + char[strlen(other._lastName) + 1]; + } + + contact& operator =(const Contact& other) { + if (this != &other) { + delete[] _firstName; + delete[]_lastName; + } + + return 0; + } + + Contact(Contact&& other) { + _firstName = other._firstName; + _lastName = other._lastName; + + other._firstName = nullptr; + other._lastName = nullptr; Contact() = default; Contact() { |