Struct NODE
{
int Data;
NODE *Next;
};
class Queue
{
NODE *Rear,*Front;
public:
Queue(){Rear=NULL;Front=NULL;}
Void Qinsert();
Void Qdelete();
Void Qdisplay();
~Queue();
};
_______________________________________________________________
void Queue::Qinsert()
{
NODE *Temp;
Temp=new NODE;
Cout<<”Data:”;
Cin>>Temp->Data;
Temp->Next=NULL;
If (Rear==NULL)
{
Rear=Temp;
Front=Temp;
}
else
{
Rear->Next=Temp;
Rear=Temp;
}
}
_______________________________________________________________
void Queue::Qdelete()
{
if (Front!=NULL)
{
NODE *Temp=Front;
Cout<
Front=Front->Next;
Delete Temp;
If (Front==NULL) Rear=NULL;
else
cout<<”Queue Empty..”;
}
_______________________________________________________________
void Queue::Qdisplay()
{
NODE *Temp=Front;
While(Temp!=NULL)
{
cout<
Temp=Temp->Next;
}
_______________________________________________________________
void Queue::~Queue()//Destructer Function
{
while (Front!=NULL)
{
NODE *Temp=Front;
Front=Front->Next;
delete Temp;
}
}
_______________________________________________________________
void main()
{
Queue QU; char Ch;
do
{
}while (Ch!=’Q’);
}
_______________________________________________________________
No comments:
Post a Comment