From dba2170b1e297b4108500d0dca38b1b53283e18a Mon Sep 17 00:00:00 2001 From: Connor McDowell Date: Fri, 8 Mar 2024 14:36:01 -0800 Subject: contact list class copied in writing contact class --- My structures/Contact.hpp | 88 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/My structures/Contact.hpp b/My structures/Contact.hpp index 5a53fea..0877b1a 100644 --- a/My structures/Contact.hpp +++ b/My structures/Contact.hpp @@ -1,12 +1,100 @@ #ifndef CONTACT_HPP #define CONTACT_HPP +#include +using namespace std; + namespace myStructures { + template + class contact + { + public: + // constructors and destructors. + contact() = default; + + ~contact() = default; + + contact(const contact& copy); + contact& operator=(const contact& rhs); + + + contact(contact&& move); + contact& operator=(contact&& rhs); + + + //getters and setters + + string Get_firstName(); + void Set_firstName(string firstName); + + string Get_lastName(); + void Set_lastName(string lastName); + + string Get_streetAddress(); + void Set_streetAddress(string streetAddress); + + string Get_city(); + void Set_city(string city); + + string Get_state(); + void Set_state(string state); + + int Get_zip(); + void Set_zip(int zip); + + string Get_email(); + void Set_email(string email); + + size_t Get_a(); + void Set_a(size_t a); + + size_t Get_id(); + void Set_id(size_t id); + + void print(); + + private: + size_t _a = 0; + // _a functions as delete bool. if a = 1, the slot is overwritten + int _id; + string _firstName; + string _lastName; + string _streetAddress; + string _city; + string _state; + int _zip; + string _email; + + }; + + + + + + + template + class ContactList + { + public: + ContactList() = default; + ContactList(size_t size); //Creates contact list of this size + ContactList(const CList* contacts, const size_t& length); //Makes a copy of another contact list + ~ContactList(); + ContactList(const ContactList& copy); //deep copy constructor + ContactList& operator=(const ContactList& rhs); //deep copy assignment + ContactList(ContactList&& move); //reference(move) constructor + ContactList& operator=(ContactList&& rhs); //reference(move) assignment + private: + CList* contacts_{ nullptr }; + size_t length_{ 0 }; + size_t size_{ 0 }; + CList* AllocateContactList(const size_t& size); + }; } -- cgit v1.2.3