Include
Include
Include
2.
#include<iostream>
struct Node{
int data;
Node *next;
};
class Queue{
public:
Node *front,*back;
Queue()
{front=back=NULL;}
void deleteitem();
void display();
~Queue();
};
if(temp==NULL){
cout<<"Overflow"<<endl;
return;
temp->data=n;
temp->next=NULL;
if (front==NULL){
front=back=temp;
else
{ back->next=temp;
back=temp;
void Queue::display(){
if (front==NULL){
cout<<"Underflow."<<endl;
return;
Node *temp=front;
while(temp){
cout<<temp->data<<" ";
temp=temp->next;
cout<<endl;
if (front==NULL){
cout<<"underflow"<<endl;
return;
}
cout<<front->data<<" is being deleted "<<endl;
front=back=NULL;
else
front=front->next;
Queue ::~Queue()
while(front!=NULL)
Node *temp=front;
front=front->next;
delete temp;
back=NULL;
int main(){
Queue Q;
Q.display();
Q.insert(10);
Q.insert(24);
Q.insert(28);
Q.insert(32);
Q.insert(30);
Q.display();
Q.deleteitem();
Q.deleteitem();
Q.deleteitem();
Q.deleteitem();
Q.deleteitem();
return 0;