#include <iostream>
#include <string>
#include "stack.h"
using namespace std;
template <class T>
CCirqueue<T>::CCirqueue() {
rear = front = 0;
}
template <class T>
void CCirqueue<T>::Push(const T &val) {
if ((rear + 1)%MAX == front)
cont << "队满\n";
else {
rear = (rear + 1)%MAX;
s[rear] = val;
}
}
template <class T>
T CCirqueue<T>::Pop() {
T temp;
if (front == rear)
cont << "队空\n";
else {
front = (front + 1)%MAX;
temp = s[front];
}
return temp;
}
头文件
#ifndef CCIRQUEUE_H_
#define CCIRQUEUE_H_
const int MAX = 100;
template <class T>
class CCirqueue {
public:
CCirqueue();
void Pushqueue(const T &val);
T Popqueue();
bool Queuefull();
bool Queueempty();
private:
T s[MAX];
int rear, front;
};
#endif