Question: A linked list is built in this lab. Make sure to keep track of the head node. (1) Define the class ContactNode per the following

A linked list is built in this lab. Make sure to keep track of the head node.

(1) Define the class ContactNode per the following specifications:

Private data members

string contactName

string contactPhoneNumber

ContactNode* nextNodePtr

Constructor with parameters for name followed by phone number (1 pt)

Public member functions

GetName() - Accessor (1 pt)

GetPhoneNumber() - Accessor (1 pt)

InsertAfter() (2 pts)

GetNext() - Accessor (1 pt)

PrintContactNode()

Ex: If the name is Roxanne Hughes and the phone number is 443-555-2864, PrintContactNode() outputs:

Name: Roxanne Hughes Phone number: 443-555-2864 

(2) Define main() to read the name and phone number for three contacts and output each contact. Create three ContactNodes and use the nodes to build a linked list. (2 pts)

Ex: If the input is:

Roxanne Hughes 443-555-2864 Juan Alberto Jr. 410-555-9385 Rachel Phillips 310-555-6610 

the output is:

Person 1: Roxanne Hughes, 443-555-2864 Person 2: Juan Alberto Jr., 410-555-9385 Person 3: Rachel Phillips, 310-555-6610 

(3) Output the linked list using a loop to output contacts one at a time. (2 pts)

Ex:

CONTACT LIST Name: Roxanne Hughes Phone number: 443-555-2864 Name: Juan Alberto Jr. Phone number: 410-555-9385 Name: Rachel Phillips Phone number: 310-555-6610 

Code:

#include using namespace std;

class ContactNode { public: /* Declare member functions here */ private: /* Declare data members here */ };

/* Define member functions here */

int main() { /* Type your code here. */ return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!