Question: This is data structure class. I need a code in C++. Please, give screen shot of running program. Below is my program, it is a
This is data structure class. I need a code in C++. Please, give screen shot of running program. Below is my program, it is a linked list with 2 nodes.
You can use this or write a similar one.
I am trying to write 2 functions. One function will add another node at the end of the list. The other function will delete a node. Please, do not use dangling pointers !
Thank you.
#includeusing namespace std; class Node { int data; Node *next; public: void setdata(int d) {data = d;} void setnext(Node *p) { next = p; } int getdata() {return data;} Node getnext() {return *next;} }; int main() { Node *N1 = new Node; N1->setdata(1000); Node *N2 = new Node; N2->setdata(2000); N1->setnext( N2) ; N2->setnext(NULL); system("pause"); return 0; }
#include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
