Member Avatar

Que.h Header file

template < class T>
class Que{

public :
	Que(int max);
	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(){
    front = 0; rear = 0 ; count =0;
	Items =new T [maxQue];              //Dynamic Memory Allocation 
template < class T >
Que< T >::Que(int max){

	front =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())
	else {

		Items[rear] = newItem;
		rear= (rear+ 1)%maxQue;
		++count ;
template < class T >
void Que< T >::Remove(T & item){

	item= Items[rear];
	front = (front+1)%maxQue;

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"

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){
	int IsEmpty();
	int IsFull();
	void PqInsert();
	void PqRemove();

template < class T >
priorityQue< T>::IsEpmty(){
	return (count ==0);

int main()
return 0;

Recommended Answers

All 2 Replies

You need to make sure that it maintains a heap structure, that is the highest priority( or the lowest) is constantly at the top. So whenever a user inserts or deletes a node, you still need to maintain that property. There are several ways of doing this, check here for details.

Member Avatar

I need more help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.