diff options
| -rw-r--r-- | Project1/contact.cpp | 6 | ||||
| -rw-r--r-- | Project1/contact.h | 3 | ||||
| -rw-r--r-- | Project1/main.cpp | 16 |
3 files changed, 24 insertions, 1 deletions
diff --git a/Project1/contact.cpp b/Project1/contact.cpp index c6d670f..e4ba37e 100644 --- a/Project1/contact.cpp +++ b/Project1/contact.cpp @@ -25,6 +25,12 @@ contact& contact::operator=(const contact& rhs) return *this; } +contact::contact(contact&& move) +{ + *this = move; + //also *this = std::move(move); +} + void contact::Set_firstName(const char* firstName) { diff --git a/Project1/contact.h b/Project1/contact.h index 58de6f6..65d1b6f 100644 --- a/Project1/contact.h +++ b/Project1/contact.h @@ -14,9 +14,12 @@ class contact { public: contact() = default; + contact(const contact& copy); contact& operator=(const contact& rhs); + contact(contact&& move); + const char* Get_firstName(); void Set_firstName(const char* firstName); diff --git a/Project1/main.cpp b/Project1/main.cpp index cb0a77b..6e853a5 100644 --- a/Project1/main.cpp +++ b/Project1/main.cpp @@ -23,9 +23,23 @@ int main() newContact.Set_zip(97035); newContact.Set_email("[email protected]"); - newContact = newContact; + contact anotherContact; + + anotherContact.Set_firstName("Soup"); + anotherContact.Set_lastName("Mchonkey"); + anotherContact.Set_streetAddress("your mom road"); + anotherContact.Set_city("Nunya"); + anotherContact.Set_state("south carolina"); + anotherContact.Set_zip(696969); + anotherContact.Set_email("[email protected]"); newContact.print(); + anotherContact = newContact; + + contact copyContact(anotherContact); + + copyContact.print(); + return 0; }
\ No newline at end of file |