Question: point for the console application. / / #include stdafx.h #include #include using namespace std; struct Node { int data; string x; Node * next;

point for the console application.
//
#include "stdafx.h"
#include
#include
using namespace std;
struct Node
{
int data;
string x;
Node* next; //it will contain pointer to the next node in the list.
};
class LinkedList
{
private:
Node* head; //pointing to the first node in the list
public:
LinkedList()
{
head=nullptr;
}
void insert(int data, string b)
{
Node* new_node = new Node();
new_node->data = data;
new_node->x = b;
new_node->next = nullptr;
if(head==nullptr)
{
head = new_node;
}
else
{
Node* temp = head;
while(temp->next!=nullptr)
{
temp = temp->next;
}
temp->next = new_node; //this points to last current node in list
}
}
void display()
{
Node* temp = head;
while(temp!=nullptr)
{
coutdata==value)
{
head = temp->next;
delete temp; //to free the memory
}
while(temp!=nullptr && temp->data!=value)
{
prev = temp;
temp = temp->next;
}
if(temp==nullptr)//if list is empty
{
cout<<"Item is not in the list";
return;
}
prev->next = temp->next;
delete temp;
}
};
int main(){
LinkedList l;
l.insert(10, "Ahmed");
l.insert(20, "bob");
l.insert(30, "Ali");
l.insert(40, "Moha");
l.insert(50, "Abdi");
l.insert(60, ali");
cout<<"Below is the inserted list of Items : ";
l.display();
cout<
add this to search function and updata function. write c++ program

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!