C++这个程序为什么会这样
.cpp(126) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
那个高手帮我解决一下 谢谢啦
#ifndef LinkNode_H
#define LinkNode_H
#ifndef LinkedStack
#define LinkedStack
#include
using namespace std;
template
struct LinkNode
{
Type data;
LinkNode *link;
LinkNode(LinkNode *ptr=NULL) {link=ptr;}
LinkNode(const Type& item, LinkNode *ptr=NULL)
{data=item;link=ptr;}
};
template
class Stack
{
public:
Stack(){};
virtual void Push(const Type &item)=0;
virtual bool Pop(Type &item)=0;
virtual bool GetTop(Type &item) const=0;
virtual bool IsEmpty() const=0;
virtual int getSize() =0;
};
template
class LinkedStack:public Stack
{
public:
LinkedStack():top(NULL){}
~LinkedStack(){MakeEmpty();}
void Push(const Type &item);
bool Pop(Type &item);
bool GetTop(Type &item) const;
bool IsEmpty() const{return (top==NULL) ? true:false;}
int getSize() ;
void MakeEmpty();
// friend ostream& operator<<(ostream& os,SeqStack &s);
private:
LinkNode *top;
};
template
void LinkedStack::Push(const Type& item)
{
top=new LinkNode(item,top);
assert(top!=NULL);
};
template
bool LinkedStack::Pop(Type& item)
{
if (IsEmpty()==true)
return false;
LinkNode *p=top;
top=top->link;
item=p->data;delete p;
return true;
};
template bool
bool LinkedStack::GetTop(Type& item)const
{
if (IsEmpty()==true) return false;
item=top->data;
return true;
};
void main()
{
int number,select=6,i;
char s;
// cout<<"\n请输入栈的大小:"<// cin>>size;
LinkedStack stack;
while(select!=5)
{
cout<<"\n\t\t\t************操作菜单*****************\n";
cout<<"\t\t\t\t 1 入栈"< cout<<"\t\t\t\t 2 出栈"< cout<<"\t\t\t\t 3 取栈顶元素"< cout<<"\t\t\t\t 4 栈中元素个数"< cout<<"\t\t\t\t 5 退出"< cout<<"\t\t\t************请选择序号*****************\n";
cin>>select;
switch(select)
{
case 1:
cout<<"请输入一个字符串并以.结束"< cin>>s;
while(s!='.')
{
stack.Push(s);
cin>>s;
}
break;
case 2:
cout<<"请输入出栈字符数:";
cin>>number;
cout<<"\n出栈元素依次为:";
for(i=0;i if (stack.Pop(s))
cout< break;
case 3:
if (!stack.GetTop(s)){cout<<"栈空"< cout<<"栈顶元素为:"< break;
case 4:
cout<<"栈中元素个数为:"< break;
case 5:
break;
}
}
cout<<"谢谢使用"<}