1.

Write the definition of functions for the linked implemented queue containing passenger information as follows: struct NODE{ int Ticketno;char PName[20];NODE * NEXT; };class Queueofbus{ NODE *Rear, *Front;public:Queueofbus(){ Rear = NULL;Front = NULL; };void Insert();void Delete();~Queueofbus(){ cout<<"Object destroyed"; }};

Answer»

void Queueofbus::Insert()

{ NODE *p = new NODE;

cout<<”Enter Ticket no”

cin>>p->ticketno;

cout<<”Enter Name”;

cin>>p->Pname;

p->NEXT = NULL;

if (rear == NULL)

{ Rear = p;

Front = Rear;

}

else

{ Rear -> NEXT = p;

Rear = Rear -> NEXT;

}

}



Discussion

No Comment Found

Related InterviewSolutions