aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsahel <[email protected]>2024-03-08 09:49:58 -0800
committerAsahel <[email protected]>2024-03-08 09:49:58 -0800
commit341872c09593f41cbe27326d9462d4f7d7668ebd (patch)
tree8c42ec86c4653661e819805bf5dd5c365ef6c28d
parentImplemented copy and move constructor (diff)
downloadin-class-exercise-14-asahellt-main.tar.xz
in-class-exercise-14-asahellt-main.zip
implemented copy constructor and added filesHEADmain
-rw-r--r--InclassExercise14/Contact.cpp25
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() {