#ifndef QUETYPE_H
#define QUETYPE_H
#ifndef QUEUE_H
#define QUEUE_H
// File: queue1.h
// Header file for Queue ADT
// Class is templated; items are in dynamically allocated storage.
template<class ItemType>
class QueType
{
public:
QueType();
// Class constructor.
// Because there is a default constructor, the precondition that the queue
// has been initialized is omitted.
QueType(int max);
// Parameterized class constructor.
~QueType();
// Class destructor.
void MakeEmpty();
// Function: Initializes the queue to an empty state.
// Post: Queue is empty.
bool IsEmpty() const;
// Function: Determines whether the queue is empty.
// Post: Function value = (queue is empty)
bool IsFull() const;
// Function: Determines whether the queue is full.
// Post: Function value = (queue is full)
void Enqueue(ItemType newItem);
// Function: Adds newItem to the rear of the queue.
// Pre: Queue is not full.
// Post: newItem is at the rear of the queue.
void Dequeue(ItemType& item);
// Function: Removes front item from the queue and returns it in item.
// Pre: Queue is not empty.
// Post: Front element has been removed from the queue.
// item is a copy of the removed element.
int QueSize() const;
// Function: Returns the number of elements in the queue
private:
int front, rear;
int size;
ItemType* items;
int maxQue;
};
#endif // QUEUE_H
#endif // QUETYPE_H
#include "QueType.h"
template<class ItemType>
QueType<ItemType>::QueType(int max)
// Paramaterized class constructor
// Post: maxQue, front, and rear have been initialized.
// The array to hold the queue elements has been dynamically allocated.
{
maxQue = max + 1;
front = maxQue - 1;
rear = maxQue - 1;
size = 0;
items = new ItemType[maxQue];
}
template<class ItemType>
QueType<ItemType>::QueType() // Default class constructor
// Post: maxQue, front, and rear have been initialized.
// The array to hold the queue elements has been dynamically allocated.
{
maxQue = 501;
front = maxQue - 1;
rear = maxQue - 1;
size = 0;
items = new ItemType[maxQue];
}
template<class ItemType>
QueType<ItemType>::~QueType() // Class destructor
{
delete [] items;
}
template<class ItemType>
void QueType<ItemType>::MakeEmpty()
// Post: front and rear have been reset to the empty state
// and size has been set to zero.
{
front = maxQue - 1;
rear = maxQue - 1;
size = 0;
}
template<class ItemType>
bool QueType<ItemType>::IsEmpty() const
// Returns true if the queue is empty; false otherwise.
{
return (rear == front);
}
template<class ItemType>
bool QueType<ItemType>::IsFull() const
// Returns true if the queue is full; false otherwise.
{
return ((rear + 1) % maxQue == front);
}
template<class ItemType>
void QueType<ItemType>::Enqueue(ItemType newItem)
// Post: newItem is at the rear of the queue.
{
rear = (rear +1) % maxQue;
items[rear] = newItem;
size++;
}
template<class ItemType>
void QueType<ItemType>::Dequeue(ItemType& item)
// Post: The front of the queue has been removed and a copy returned in item.
{
front = (front + 1) % maxQue;
item = items[front];
size--;
}
template<class ItemType>
int QueType<ItemType>::QueSize() const
{
return size;
}
waitingCustomerQueueType.cpp
#include "waitingCustomerQueueType.h"
waitingCustomerQueueType::waitingCustomerQueueType(int taille): QueType<JobType>QueType(taille)
{
//ctor
}
waitingCustomerQueueType::~waitingCustomerQueueType()
{
//dtor
}
@UK Marine They are already defined, I am trying to implement the overloaded constructor inwaintingCustomerQueueType which inherits from a tamplate class.
The proble is in inheriting from the template class ! the structor is wrong But I can't get where .