aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor McDowell <[email protected]>2024-03-08 14:54:41 -0800
committerConnor McDowell <[email protected]>2024-03-08 14:54:41 -0800
commita6ccb3a8a556394aa806e58af4c97de3bbd05118 (patch)
treeb47db5e5dbf7d4dcd260bb9d33514228de283718
parentcontact list class copied in (diff)
downloadhomework-8-connormcdowell275-a6ccb3a8a556394aa806e58af4c97de3bbd05118.tar.xz
homework-8-connormcdowell275-a6ccb3a8a556394aa806e58af4c97de3bbd05118.zip
Contact class gets, sets, and print initialized
-rw-r--r--My structures/Contact.hpp151
-rw-r--r--Project1/main.cpp30
2 files changed, 157 insertions, 24 deletions
diff --git a/My structures/Contact.hpp b/My structures/Contact.hpp
index 0877b1a..f13ace6 100644
--- a/My structures/Contact.hpp
+++ b/My structures/Contact.hpp
@@ -15,12 +15,12 @@ namespace myStructures
~contact() = default;
- contact(const contact& copy);
- contact& operator=(const contact& rhs);
+ contact(const contact& copy); // copy constructor
+ contact& operator=(const contact& rhs); // copy assignment
- contact(contact&& move);
- contact& operator=(contact&& rhs);
+ contact(contact&& move) noexcept; // move constructor
+ contact& operator=(contact&& rhs) noexcept; // move assignment
//getters and setters
@@ -65,40 +65,147 @@ namespace myStructures
string _state;
int _zip;
string _email;
+ C custom_value{};
};
+ // constructor defs for CLASS CONTACT
+ template <class C>
+ contact<C>::contact(const contact& copy)
+ {
+ }
+ template <class C>
+ contact<C>& contact<C>::operator=(const contact& rhs)
+ {
+ }
- template <class CList>
- class ContactList
+ template <class C>
+ contact<C>::contact(contact&& move)
{
- 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
+ template <class C>
+ contact<C>& contact<C>::operator=(contact&& rhs)
+ {
- private:
- CList* contacts_{ nullptr };
- size_t length_{ 0 };
- size_t size_{ 0 };
+ }
- CList* AllocateContactList(const size_t& size);
- };
-}
+ // getter and setter defs for CLASS CONTACT
+ template <class C>
+ string contact<C>::Get_firstName()
+ {
+ return _firstName;
+ }
+ template <class C>
+ void contact<C>::Set_firstName(string firstName)
+ {
+ _firstName = firstName;
+ }
+ template <class C>
+ string contact<C>::Get_lastName()
+ {
+ return _lastName;
+ }
+ template <class C>
+ void contact<C>::Set_lastName(string lastName)
+ {
+ _lastName = lastName;
+ }
+ template <class C>
+ string contact<C>::Get_streetAddress()
+ {
+ return _streetAddress;
+ }
+ template <class C>
+ void contact<C>::Set_streetAddress(string streetAddress)
+ {
+ _streetAddress = streetAddress;
+ }
+ template <class C>
+ string contact<C>::Get_city()
+ {
+ return _city;
+ }
+ template <class C>
+ void contact<C>::Set_city(string city)
+ {
+ _city = city;
+ }
+ template <class C>
+ string contact<C>::Get_state()
+ {
+ return _state;
+ }
+ template <class C>
+ void contact<C>::Set_state(string state)
+ {
+ _state = state;
+ }
+
+ template <class C>
+ int contact<C>::Get_zip()
+ {
+ return _zip;
+ }
+ template <class C>
+ void contact<C>::Set_zip(int zip)
+ {
+ _zip = zip;
+ }
+
+ template <class C>
+ string contact<C>::Get_email()
+ {
+ return _email;
+ }
+ template <class C>
+ void contact<C>::Set_email(string email)
+ {
+ _email = email;
+ }
+
+ template <class C>
+ size_t contact<C>::Get_a()
+ {
+ return _a;
+ }
+ template <class C>
+ void contact<C>::Set_a(size_t a)
+ {
+ _a = a;
+ }
+
+ template <class C>
+ size_t contact<C>::Get_id()
+ {
+ return _id;
+ }
+ template <class C>
+ void contact<C>::Set_id(size_t id)
+ {
+ _id = id;
+ }
+
+ template <class C>
+ void contact<C>::print()
+ {
+ cout << "Contact number: " << _id << endl;
+ cout << "Full name: " << _firstName << " " << _lastName << endl;
+ cout << "Street Address: " << _streetAddress << endl;
+ cout << "City: " << _city << endl;
+ cout << "State: " << _state << endl;
+ cout << "Zip code: " << _zip << endl;
+ cout << "Email: " << _email << endl;
+ }
+}
#endif CONTACT_HPP \ No newline at end of file
diff --git a/Project1/main.cpp b/Project1/main.cpp
index e588a9d..14f761b 100644
--- a/Project1/main.cpp
+++ b/Project1/main.cpp
@@ -13,8 +13,34 @@ using namespace myStructures;
int main()
{
+ contact<char> newContact;
+ contact<int> intContact;
+ return 0;
+}
- return 0;
-} \ No newline at end of file
+// contact list class below, holding for later.
+
+//template <class CList>
+//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);
+//}; \ No newline at end of file