Make a list using linked list approach according to thespecification given below
ID: 3613900 • Letter: M
Question
Make a list using linked list approach according to thespecification given below
1.1 A class Student that contains student name, student ID andthe marks %.
1.2 A class Studentlist that contains a number of objectsStudent.
Note: At this point of time, you do not have to store themaccording to their
position.
1.3 Implement the following functions for the Studentlistclass:
b. empty() - check whether the list is empty.
c. insert(int pos, Student &item), where pos is the positionin the list. The
position in the list starts from 0;
Note that you need to consider the special
case when pos=0 and when pos is equal to the size of yourlist.
Explanation / Answer
#include using namespace std;class Student{public:Student(){}Student(char *n,int id,float m){strcpy(name,n);Student_ID = id;marks = m;}char name[100];int Student_ID;float marks;};class Studentlist{private:struct node{Student data;node *link;}*p;public:Studentlist();void insert( int c, Student &data );void del( int num );void display();int count();~Studentlist();};Studentlist::Studentlist(){p=NULL;}void Studentlist::insert( int c, Student &num){node *q,*t;int i;if(p == NULL){p= new node;p->data = num;p->link=NULL;return;}if(cdata = num;t->link = p;p=t;return;}for(i=0,q=p;ilink;if( q == NULL ){coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.