这个要细心啊。很多问题都是不细心导致的。你main函数里面没写所以我只改了你错的地方,请看代码后的注释。
#include
using namespace std;
template
class Stack
{
public:
explicit Stack(int capacity = 10);
bool IsEmpty()const;
bool IsFull()const;
void MakeEmpty(){ top = -1; }
void Pop();
void Push(const Object&);
Object TopAndPop();
const Object&Top() const;
~Stack()
{
if (theArray)
{
delete[]theArray;
}
theArray = NULL;
}
private:
int MaxSize;
int top;
Object*theArray;
};
template
Stack