| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 740 人关注过本帖
标题:unexcepted end of file found
只看楼主 加入收藏
淡雅蜻蜓
Rank: 1
等 级:新手上路
帖 子:23
专家分:8
注 册:2010-11-21
结帖率:25%
收藏
 问题点数:0 回复次数:0 
unexcepted end of file found
.cpp(126) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
那个高手帮我解决一下  谢谢啦
#ifndef LinkNode_H
#define LinkNode_H
#ifndef  LinkedStack
#define  LinkedStack
#include <iostream.h>
using namespace std;

template<class Type>
struct LinkNode
{
        Type data;
        LinkNode<Type> *link;
        LinkNode(LinkNode<Type> *ptr=NULL) {link=ptr;}
        LinkNode(const Type& item, LinkNode<Type> *ptr=NULL)
        {data=item;link=ptr;}        
};

template<class Type>
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 Type>
class LinkedStack:public Stack<Type>
{
    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<Type> &s);
    private:
        LinkNode<Type> *top;
};

template <class Type>
void LinkedStack<Type>::Push(const Type& item)
{
    top=new LinkNode<Type>(item,top);
    assert(top!=NULL);
};

template <class Type>
bool LinkedStack<Type>::Pop(Type& item)
{
    if (IsEmpty()==true)
      return false;
    LinkNode<Type> *p=top;
    top=top->link;
    item=p->data;delete p;
    return true;
};

template <class Type> bool
 bool LinkedStack<Type>::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请输入栈的大小:"<<endl;
//    cin>>size;
    LinkedStack<char> stack;
    while(select!=5)
     {
        cout<<"\n\t\t\t************操作菜单*****************\n";
        cout<<"\t\t\t\t 1 入栈"<<endl;
        cout<<"\t\t\t\t 2 出栈"<<endl;
        cout<<"\t\t\t\t 3 取栈顶元素"<<endl;
        cout<<"\t\t\t\t 4 栈中元素个数"<<endl;
        cout<<"\t\t\t\t 5 退出"<<endl;
        cout<<"\t\t\t************请选择序号*****************\n";
        cin>>select;
        switch(select)
        {
         case 1:
            cout<<"请输入一个字符串并以.结束"<<endl;
            cin>>s;
            while(s!='.')
            {
              stack.Push(s);
              cin>>s;
             }
            break;
         case 2:
             cout<<"请输入出栈字符数:";
             cin>>number;
             cout<<"\n出栈元素依次为:";
             for(i=0;i<number;i++){
               if (stack.Pop(s))
                   cout<<s<<"  ";}
             break;
         case 3:
             if (!stack.GetTop(s)){cout<<"栈空"<<endl;break;}
             cout<<"栈顶元素为:"<<Stack. GetTop();
             break;
         case 4:            
             cout<<"栈中元素个数为:"<<Stack.getSize( );
             break;
         case 5:
             break;
        }
     }
       cout<<"谢谢使用"<<endl;
}

搜索更多相关主题的帖子: found unexcepted end file 
2010-11-21 17:27
快速回复:unexcepted end of file found
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011677 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved