Question: Where is the error I want to fix my code I want to change the last number like the image #include using namespace std; struct
Where is the error I want to fix my code
I want to change the last number
like the image
#include
using namespace std;
struct node
{ int info;
node *next;
};
class clist
{
private:
node *head;
public:
clist(){head=new node; head->next=head;}
void traverse()
{
if(head->next==head)
cout
else
{
node*curr=head->next;
while(curr!=head)
{
coutinfo
curr=curr->next;
}
cout
}
}
void add(int item)
{ node*p=new node;
p->info=item;
node*per=head;
node*curr=head->next;
if(curr!=head){
per=curr;
per=per->next;
curr->next=p;
p->next=per; }
{
if(head->next==head){
p->next=head;
head->next=p;}
}
}
void change (int value)
{ node*curr=head->next;
curr=curr->next;
if(curr!=head){
curr->info=8;}
}
};
int main()
{
clist s;
s.add(4);
cout
s.traverse();
s.add(3);
cout
s.traverse();
s.add(6);
cout
The list after calling 'change' function with parameter ' 8 ': 468 Program ended with exit code: 0 s.traverse();
s.change(8);
cout
s.traverse();
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
