diff options
Diffstat (limited to 'Homework8/MyStructures/Contact.hpp')
| -rw-r--r-- | Homework8/MyStructures/Contact.hpp | 78 |
1 files changed, 20 insertions, 58 deletions
diff --git a/Homework8/MyStructures/Contact.hpp b/Homework8/MyStructures/Contact.hpp index ac480be..fdc2921 100644 --- a/Homework8/MyStructures/Contact.hpp +++ b/Homework8/MyStructures/Contact.hpp @@ -22,7 +22,7 @@ namespace MyStructures //variables declared here act as a global Contact() = default; Contact(char* name, const short age); - ~Contact(); + ~Contact() = default; Contact(const Contact& copy); //copy constructor Contact& operator=(const Contact& rhs); //copy assignment @@ -52,10 +52,9 @@ namespace MyStructures //variables declared here act as a global int GetZip(); void SetZip(int zip); - /*int InputInt(const char* prompt);*/ - /*char* PromptCharInput(const char* prompt, long long maxlen);*/ - + bool operator != (const Contact & rhs) const; + bool operator == (const Contact& rhs) const; void Print() const; @@ -80,17 +79,11 @@ namespace MyStructures //variables declared here act as a global } - inline Contact::~Contact() - { + //inline Contact::~Contact() + //{ - delete[] firstname_; - delete[] lastname_; - delete[] email_; - delete[] street_; - delete[] state_; - delete[] city_; - - } + + //} inline Contact::Contact(const Contact& copy) @@ -134,7 +127,7 @@ namespace MyStructures //variables declared here act as a global inline Contact::Contact(Contact&& move) { - *this = move; + *this = std::move(move); } @@ -225,49 +218,6 @@ namespace MyStructures //variables declared here act as a global } - /*inline int Contact::InputInt(const char* prompt) - { - std::cout << prompt << std::endl; - - std::cout.flush(); - - int data = 0; - std::cin >> data; - - while (!std::cin) - { - std::cout << prompt << std::endl; - std::cin.clear(); - - cin.ignore(MAX_STREAM_SIZE, '\n'); - std::cin >> data; - - } - - return data; - }*/ - - //inline char* Contact::PromptCharInput(const char* prompt, long long maxlen) - //{ - // char* input = new char[maxlen]; - // std::cout.flush(); - - // std::cout << prompt << std::endl; - // cin.get(input, maxlen, '\n'); - // cin.ignore(MAX_STREAM_SIZE, '\n'); - // - // while (!std::cin) - // { - // std::cout << prompt << std::endl; - - // std::cin.clear(); - // - // cin.get(input, maxlen, '\n'); - - // } - // - // return input; - //} inline bool Contact::operator!=(const Contact& rhs) const { @@ -282,6 +232,18 @@ namespace MyStructures //variables declared here act as a global return false; } + inline bool Contact::operator==(const Contact& rhs) const + { + if (std::strcmp(firstname_, rhs.firstname_) != 0) { return false; } + if (std::strcmp(lastname_, rhs.lastname_) != 0) { return false; } + if (std::strcmp(email_, rhs.email_) != 0) { return false; } + if (std::strcmp(street_, rhs.street_) != 0) { return false; } + if (std::strcmp(state_, rhs.state_) != 0) { return false; } + if (std::strcmp(city_, rhs.city_) != 0) { return false; } + if (zip_ != rhs.zip_) { return false; } + return true; + } + void Contact::Print() const |