Can any one help, I dont understand what I am really doing and having trouble wrapping my head around the meaning of my class and its members and the member functions.
This is my assignment
Assignment Two - Contacts (Linked List)
You will be building a linked list. Make sure to keep track of both the head and tail nodes.
(1) Create three files to submit
• Contacts.h - Class declaration
• Contacts.cpp - Class definition
• main.cpp - main() function
(2) Build the node class for your contacts per the following specifications:
• Parameterized constructor. Parameters are name followed by phone number.
• Public member functions
o InsertAfter()
o GetName() - Accessor
o GetPhoneNumber - Accessor
o GetNext() - Accessor
o PrintContactNode()
• Private data members
o string contactName
o string contactPhoneNum
o ContactNode* nextNodePtr
Example. of PrintContactNode() output:
Name: Roxanne Hughes
Phone number: 443-555-2864
(3) In main(), prompt the user for three contacts and output the user's input. Create three ContactNodes and use the nodes to build a linked list.
Example:
Person 1
Enter name:
Roxanne Hughes
Enter phone number:
443-555-2864
You entered: Roxanne Hughes, 443-555-2864
Person 2
Enter name:
Juan Alberto Jr.
Enter phone number:
410-555-9385
You entered: Juan Alberto Jr., 410-555-9385
Person 3
Enter name:
Rachel Phillips
Enter phone number:
310-555-6610
You entered: Rachel Phillips, 310-555-6610
(4) Output the linked list.
Example:
CONTACT LIST
Name: Roxanne Hughes
Phone number: 443-555-2864
#include <iostream>
#include <vector>
#include <string>
usingnamespace std;
#include "Contacts.h"
int main(){
cout << "Please Enter the Contact information for three people:\n"; //<--
int numCont = 3; //<--
for (int i = 0; i < numCont; i++){
cout << "Person " << i+1<< ":" << endl << "Enter Name: " << endl;
//cin >> ????
}
return 0;
}
Your code is OK as far as it goes. To get it to run there need to be a few changes marked with the arrows. Some needs to be completed such as the cin statement to create a new contact and therefor a new node.
Once you can create individual contacts and get them working you can then add them as nodes (pointers) to the linked list you build into the Class. You need head node class member etc as for an ordinary linked list