| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 670 人关注过本帖
标题:C++这个程序为什么会这样
取消只看楼主 加入收藏
淡雅蜻蜓
Rank: 1
等 级:新手上路
帖 子:23
专家分:8
注 册:2010-11-21
结帖率:25%
收藏
已结贴  问题点数:20 回复次数:0 
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<<"谢谢使用"<}

搜索更多相关主题的帖子: 126 unexpected include public 
2010-11-21 17:50
快速回复:C++这个程序为什么会这样
数据加载中...
 
   



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

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