Question: / / main . cpp / / File: main.cpp #include SinglyLinkedList.h #include #include #include using namespace std; Node * listSearch ( LinkedList * list,

//main.cpp
// File: main.cpp
#include "SinglyLinkedList.h"
#include
#include
#include
using namespace std;
Node * listSearch(LinkedList * list, const int key);
string listDescriptor(LinkedList * list);
int main(){
cout "No implementation given.";
return 0;
}// end main()
Node * listSearch(LinkedList * list, const int key){
Node* current = list->head;
while (current){
if (current->next->id == key){
return current;
}
current = current->next;
}
return nullptr; // Key not found
}
string listDescriptor(LinkedList * list){
ostringstream oss;
Node* current = list->head;
while (current){
oss current->next->descriptor() endl;
current = current->next;
}
return oss.str();
}
//Person.h
#ifndef PERSON_H
#define PERSON_H
#include
#include
using namespace std;
/* class: Person
* Stores personal information
*/
class Person {
public:
int id;
string first;
string last;
Person(const int id =0, const string& first ="na", const string& last ="na")
: id{id}, first{first}, last{last}
{}
string descriptor() const {
ostringstream oss;
oss "{"
"id:" id ","
"first:" first ","
"last:" last
"}";
return oss.str();
}
};
#endif
//SinglyLinkedList.h
#ifndef SINGLY_LINKED_LIST
#define SINGLY_LINKED_LIST
#include
using namespace std;
class Node
{
public:
string name;
Node *next;
Node()
{
next = nullptr;
}
Node(string fname, string lname)
{
name = fname +""+ lname;
this->next =nullptr;
}
};
class LinkedList
{
public:
Node* head, *tail;
LinkedList()
{
head = tail = nullptr;
tail - new
}
};
#endif
/ / main . cpp / / File: main.cpp #include

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 Programming Questions!