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 is:
#include
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started