Que.h Header file
template < class T>
class Que{
public :
Que();
Que(int max);
~Que();
int isFull()const ;
int isEmpty()const ;
void Insert( T newItem);
void Remove(T & item);
private :
int front , rear;
int maxQue;
int count ;
T * Items; // Dynamic Arry Implementation
};
template < class T >
Que< T >::Que(){
maxQue=100;
front = 0; rear = 0 ; count =0;
Items =new T [maxQue]; //Dynamic Memory Allocation
}
template < class T >
Que< T >::Que(int max){
maxQue=max;
front =0;
rear=0;
count =0;
Items= new T [maxQue];
}
template < class T >
Que< T >::~Que(){
delete [] Items;
}
template < class T >
int Que< T >::isEmpty()const {
return ( count == 0);
}
template < class T >
int Que< T >::isFull()const {
return (count == maxQue);
}
template < class T >
void Que< T >::Insert( T newItem){
if (isFull())
cout<<"overFlow";
else {
Items[rear] = newItem;
rear= (rear+ 1)%maxQue;
++count ;
}
}
template < class T >
void Que< T >::Remove(T & item){
if(isEmpty())
cout<<"UnderFlow";
else
{
item= Items[rear];
front = (front+1)%maxQue;
--count;
}
}
now i want to add a class which priority Queue ..Eny one plxx help me how i make proority que class
// Implemetation of PriorityQueue.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include"Que.h"
#include<iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;
template < class T >
class PriorityQue{
private :
Que constr;
T * ptr;
int count front ,rear ;
public :
int maxQue
PriorityQue(int max):constr(int max){
maxQue=m;
}
int IsEmpty();
int IsFull();
void PqInsert();
void PqRemove();
};
template < class T >
priorityQue< T>::IsEpmty(){
return (count ==0);
}
int main()
{
//Que<int>obj;
getch();
return 0;
}