diff options
Diffstat (limited to 'Project1/program.cpp')
| -rw-r--r-- | Project1/program.cpp | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/Project1/program.cpp b/Project1/program.cpp index c887eac..d6761d5 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -3,7 +3,7 @@ // class: CST116 // reason: homework number 6 -#include "Contacts.h" +#include "Contact_list.h" #include <iostream> using std::cin; @@ -17,12 +17,12 @@ int main() size_t MAX = 3; int O = 1; /* t = index counter*/ - //contact newContact[]; - contact* newContact = new contact[MAX]; - contact_list contact_list; + contact newContact; + //contact* newContact = new contact[MAX]; + contact_list contacts(MAX); size_t t = 0; - contact_list.set_size(sizeof(newContact[MAX])); + contacts.set_size(sizeof(newContact)); while (O == 1) { //cout << MAX << endl; @@ -39,26 +39,27 @@ int main() { case 1: //addNew(newContact, MAX, t); - contact_list.AddContact(*newContact, MAX, t); - if (t >= MAX) // Check if the number of contacts exceeds MAX - { - contact* newContactTemp = new contact[MAX * 2]; // Double the size - for (size_t i = 0; i < MAX; ++i) // Copy existing contacts - newContactTemp[i] = newContact[i]; - delete[] newContact; // Deallocate old memory - newContact = newContactTemp; // Update pointer - MAX *= 2; // Update MAX - } + contacts.AddContact(newContact); + //if (t >= MAX) // Check if the number of contacts exceeds MAX + //{ + // contact* newContactTemp = new contact[MAX * 2]; // Double the size + // for (size_t i = 0; i < MAX; ++i) // Copy existing contacts + // newContactTemp[i] = newContact[i]; + // delete[] newContact; // Deallocate old memory + // newContact = newContactTemp; // Update pointer + // MAX *= 2; // Update MAX + //} + break; case 2: - contact_list.Update(*newContact, MAX); + contacts.Update(newContact, MAX); break; case 3: - contact_list.Print(newContact, MAX); // Print only the existing contacts + contacts.Print(&newContact, MAX); // Print only the existing contacts break; case 4: - contact_list.DeleteContact(newContact, MAX); - contact_list.CopyList(newContact, MAX); + contacts.DeleteContact(&newContact, MAX); + contacts.CopyList(&newContact, MAX); break; case 5: O = 0; |