洛阳建业二号城邦开盘:C++程序运行错误

来源:百度文库 编辑:神马品牌网 时间:2024/05/05 04:26:56
//"seqstack.h"
#ifndef SEQ_
#define SEQ_
#include<iostream.h>
enum ResultCode {NoMemory,OutOfBounds,Overflow,Underflow,Duplicate};
template<class T>
class Stack
{
public:
virtual void Push(const T &x)=0;
virtual void Pop()=0;
virtual T Top()const=0;
virtual bool IsEmpty()const=0;
virtual bool IsFull()const=0;
};
template<class T>
class SeqStack:public Stack<T>
{
public:
SeqStack(int mSize);
~SeqStack() {delete []s;}
bool IsEmpty()const { return (top==-1);}
bool IsFull()const { return (top==maxSize-1);}
void Push(const T &x);
void Pop();
T Top()const;
private:
void Output(ostream& out)const;
T *s;
int maxSize;
int top;
friend ostream &operator<<(ostream & out,const SeqStack<T> & a);
};
#endif

//"seqstack.cpp"
#include"seqstack.h"
#include<iostream.h>
template<class T>
SeqStack<T>::SeqStack(int mSize)
{
maxSize=mSize;
s=new T[maxSize];
top=-1;
}
template<class T>
void SeqStack<T>::Push(const T &x)
{
if(IsFull()) throw Overflow;
s[++top]=x;
}
template<class T>
void SeqStack<T>::Pop()
{
if(IsEmpty()) throw Underflow;
top--;
}
template<class T>
T SeqStack<T>::Top()const
{
if(IsEmpty()) throw Underflow;
return s[top];
}
template<class T>
void SeqStack<T>::Output(ostream& out)const
{
int i=top;
out<<endl<<"Stack contains:";
while(i!=-1) out<<s[i--]<<" ";
out<<endl;
}
template<class T>
ostream &operator<<(ostream & out,const SeqStack<T> &s)
{
s.Output(out);
return out;
}
//main.cpp
#include"seqstack.h"
#include"seqstack.cpp"
void main()
{
SeqStack<char> s(100);
char ch,y;
cout<<" "<<endl;
while(cin>>ch,ch!='#')
s.Push(ch);
if(!s.IsEmpty())
cout<<" FSD "<<endl;
while(!s.IsEmpty())
{ y=s.Top();s.Pop();cout<<y;}
cout<<endl;
}
执行错误
IBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/反向输出.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
怎么回事???

我在vc++6里面可以运行呀