Question: C++ Linked Lists Complete program with help of comments Code: #include #include using namespace std; class LL; class Node { friend class LL; private: string
C++
Linked Lists
Complete program with help of comments



Code:
#include
#include
using namespace std;
class LL;
class Node
{
friend class LL;
private:
string firstName;
string lastName;
string phoneNumber;
Node * nextRecord;
};
class LL
{
private:
Node * head;
void destroy();
public:
LL();
LL(const LL&);
~LL();
void append(string, string, string);
void insertAtBeginning(string, string, string);
void insertByPos(string, string, string, int);
void print();
void searchByName(string, string);
void updateNumber(string, string, string);
void removeRecord(string, string);
void reverse();
};
//--------------------------------------------
// the default constructor
LL::LL()
{
}
//--------------------------------------------
// the copy constructor
LL::LL(const LL& source)
{
}
//--------------------------------------------
// the destructor
LL::~LL()
{
}
//--------------------------------------------
// print the linked list
void LL::print ()
{
}
//--------------------------------------------
// search for a particular person in the list and print the
// corresponding phone number
void LL::searchByName (string fName, string lName)
{
}
//--------------------------------------------
// create a node and insert the node on the top of the
// linked list before the first node.
void LL::insertAtBeginning (string fName, string lName, string phone)
{
}
//--------------------------------------------
// create a node and appends the node at the end of the
// linked list after the last node.
void append(string fName, string lName, string phone)
{
}
//--------------------------------------------
// create a node and insert the node at the position pos
void LL::insertAtPos (string fName, string lName, string phone, int pos)
{
}
//--------------------------------------------
// remove a person's record from the list
void LL::removeRecord (string fName, string lName)
{
}
//--------------------------------------------
// Update a person's phone number
void updateNumber(string fName, string lName, string newPhone);
{
}
//--------------------------------------------
// Destroy all the nodes in the list
void LL:destroy();
//--------------------------------------------
// traverse the list and reverse the list nodes so the last node
// becomes the first and the first node becomes the last one
void LL: reverse()
{
}
//--------------------------------------------
int main ()
{
LL list1;
list1.append ("Mayssaa", "Najjar", "878-635-1234");
list1.insertAtBeginning ("Jim", "Meyer", "337-465-2345");
list1.append ("Joe", "Didier", "352-654-1983");
list1.insertAtPos ("Adam", "James", "202-872-1010", 2);
list1.insertAtBeginning("Nancy", "Garcia", "617-227-5454");
list1.print();
list1.searchByName ("Nancy", "Garcia");
list1.searchByName ("Jamie", "Garcia");
list1.updateNumber ("Nancy", "Garcia", "989-876-1234");
list1.updateNumber ("Jamie", "Garcia", "345-467-1234");
list1.removerecord ("Mayssaa", "Najjar");
list1.print();
list1.reverse();
list1.print();
LL list2(list1);
list2.print();
return 0;
}
#include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
