diff options
| author | raquelc <[email protected]> | 2024-03-21 19:12:54 -0700 |
|---|---|---|
| committer | raquelc <[email protected]> | 2024-03-21 19:12:54 -0700 |
| commit | 0bee0e333da71c5f27a8ea5265c9521d6a1b9680 (patch) | |
| tree | 87c608d475d8c769962505e96597cfd0d3ee7357 /Extercise project | |
| parent | inittial commit (diff) | |
| download | in-class-exercise-14-raquel191-0bee0e333da71c5f27a8ea5265c9521d6a1b9680.tar.xz in-class-exercise-14-raquel191-0bee0e333da71c5f27a8ea5265c9521d6a1b9680.zip | |
Diffstat (limited to 'Extercise project')
| -rw-r--r-- | Extercise project/Extercise project/contact.cpp | 50 | ||||
| -rw-r--r-- | Extercise project/Extercise project/contact.h | 16 | ||||
| -rw-r--r-- | Extercise project/Extercise project/main.cpp | 15 |
3 files changed, 73 insertions, 8 deletions
diff --git a/Extercise project/Extercise project/contact.cpp b/Extercise project/Extercise project/contact.cpp index 83298ca..7852de9 100644 --- a/Extercise project/Extercise project/contact.cpp +++ b/Extercise project/Extercise project/contact.cpp @@ -1,8 +1,54 @@ #include "contact.h" #include <iostream> +#include <array> Contact::Contact() { } +/* +Contact::Contact(const char* firstname, const short age) { + _firstname = firstname; + _age = age; +} +*/ +Contact::Contact(const Contact& copy) { + *this = copy; +} + +Contact& Contact::operator=( const Contact& rhs) { + + + if ( this != &rhs) { + _firstname = rhs._firstname; + _lastname = rhs._lastname; + _Streetaddress = rhs._Streetaddress; + _city = rhs._city; + _state = rhs._state; + _zip = rhs._zip; + _email = rhs._email; + } + return *this; +} + +Contact Contact::anothercont() +{ + + return Contact(); +} +//_age = rhs._age; + +Contact& Contact:: operator=(Contact&& rhs) { + if (this != &rhs) { + _firstname = rhs._firstname; + _lastname = rhs._lastname; + } + return *this; +} + +Contact::Contact(Contact&& move) { + *this = move; +} + +/* void Contact::SetAge(short age) { _age = age; } @@ -10,7 +56,7 @@ Contact::Contact() { } short Contact::GetAge() { return _age; } - + */ const char* Contact::Getfirstname() { return _firstname; } @@ -74,7 +120,7 @@ const char* Contact::GetEmail() { void Contact::Print() { std::cout << "First Name: " << _firstname << std::endl; std::cout << "Last Name: " << _lastname << std::endl; - std::cout << "Age: " << _age << std::endl; + //std::cout << "Age: " << _age << std::endl; std::cout << "StreetAddress: " << _Streetaddress << std::endl; std::cout << "City: " << _city << std::endl; std::cout << "State: " << _state << std::endl; diff --git a/Extercise project/Extercise project/contact.h b/Extercise project/Extercise project/contact.h index 81d45c3..57eb616 100644 --- a/Extercise project/Extercise project/contact.h +++ b/Extercise project/Extercise project/contact.h @@ -5,9 +5,16 @@ class Contact { public: Contact(); + Contact(const Contact& copy); + Contact& operator=(const Contact& rhs); + //Contact(Contact); + Contact anothercont(); - short GetAge(); - void SetAge(short age); + Contact(Contact&& move); + Contact& operator=(Contact&& rhs); + + //short GetAge(); + //void SetAge(short age); const char* Getfirstname(); void Setfirstname(const char* firstname); @@ -41,10 +48,9 @@ private: const char* _Streetaddress{ }; const char* _city{ }; const char* _state{ }; - int _zip{ 97070 }; const char* _email{}; - - short _age{ 0 }; + int _zip{ 97070 }; + //short _age{ 0 }; }; diff --git a/Extercise project/Extercise project/main.cpp b/Extercise project/Extercise project/main.cpp index 4cff080..0002df6 100644 --- a/Extercise project/Extercise project/main.cpp +++ b/Extercise project/Extercise project/main.cpp @@ -9,7 +9,7 @@ int main() { Contact newContact; - newContact.SetAge(42); + //newContact.SetAge(42); newContact.Setfirstname("Joe"); newContact.Setlastname("Blow"); newContact.SetStreetaddress("31st Street"); @@ -19,6 +19,19 @@ int main() { newContact.Print(); + + + + //anothercont = newContact; + Contact anothercont; + + //("Bacon", "eggs","34th st", "port", "land"," or ", "email@mail"); + anothercont.Print(); + + anothercont = newContact; + + Contact copyContact(anothercont); + copyContact.Print(); return 0; }
\ No newline at end of file |