该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
做数据结构实验 写了如下代码
头文件
#ifndef STACK_H
#define STACK_H
#include
template class Stack {
public:
Stack ( int=10 );
~Stack () { delete [] elements;}
void Push (const Type &item);
Type Pop ();
Type GetTop ();
void MakeEmpty () { top = -1;}
int IsEmpty () const { return top == -1;}
int IsFull () const {return top == maxSize -1;}
private:
int top;
Type *elements;
int maxSize;
};
#endif
cpp文件
#include "Stack.h"
template Stack::Stack (int s) : top(-1),maxSize(s) {
elements = new Type[maxSize];
assert(elements != 0 );
template void Stack::Push ( const Type &item ) {
assert( !IsFull() ) ;
elements[++top] = item;
}
template Type Stack::Pop() {
assert( !IsEmpty() );
return element[top--];
}
template Type Stack::GetTop(){
assert( !IsEmpty() );
return elements[top];
}
出现编译错误如下 希望高手解决下~~多谢了
C:\Documents and Settings\student\桌面\大水法\stack1\Stack.cpp(22) : fatal error C1075: end of file found before the left brace '{' at 'C:\Documents and Settings\student\桌面\大水法\stack1\Stack.cpp(3)' was matched
Error executing cl.exe.