here is my .h
const int MAX_SIZE = 10;
class PackingQueue
{
public:
PackingQueue(void);
~PackingQueue(void);
bool dequeue(int & data);
bool enqueue(int data);
bool empty();
bool full();
int info[MAX_SIZE];
};
here is my implementation
#include "PackingQueue.h"
int count = 6;
PackingQueue::PackingQueue(void)
{
info[0] = 32;
info[1] = 40;
info [2] = 35;
info [5] = 54;
info [6] = 6;
info [7] = 7;
}
bool PackingQueue::dequeue(int & data)
{
if( empty() )
return false;
data = info[0];
count = count - 1;
for(int i = 0; i < count; i++)
info[i] = info[i + 1];
return true;
}
bool PackingQueue::empty()
{
if(count = 0)
return true;
return false;
}
bool PackingQueue::enqueue(int data)
{
if(full())
return false;
info[count] = data;
count++;
return true;
}
bool PackingQueue::full()
{
if(count == MAX_SIZE)
return true;
return false;
}
PackingQueue::~PackingQueue(void)
{
}
here is a test program to test the class
#include<iostream>
#include"PackingQueue.h"
using namespace std;
const int MAX = 10;
void main()
{
PackingQueue queue;
int data;
queue.dequeue(data);
cout << data<<endl;
queue.dequeue(data);
cout << data <<endl;
}

New Topic/Question
Reply




MultiQuote




|