c++迷宫程序报错了

来源:百度知道 编辑:UC知道 时间:2024/06/09 23:34:19
template<class T>
class Stack{
public:
Stack(int MaxStackSize);

~Stack () {
delete [] stack;
}

bool IsEmpty() const {
return top == -1;
}

bool IsFull() const {
return top == MaxTop;
}

T Pop() const;//返回栈顶元素
Stack<T>& Push(const T& x);//添加元素
Stack<T>& Delete(T& x);
private:
int top; // 栈顶
int MaxTop; // 最大的栈顶值
T *stack; // 堆栈元素数组
};
*******************************
template<class T>
Stack<T>::Stack(int MaxStackSize){
MaxTop= MaxStackSize-1;
stack = new T[MaxStackSize];
top = -1;
}
*******************************
template<class T>
T Stack<T>::Pop() const{

return stack[top];
}
*******************************
template<class T>
Stack<T>& Stack<T>::Push(const T& x){

stack[++top] = x;

我这里有个c语言版的 不晓得能不能帮上你的忙
http://www.cfans8.cn/article.asp?id=746
看看吧 我觉得c和c++差不多的