免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6274 | 回复: 7
打印 上一主题 下一主题

编译时出错: fatal error C1004 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-10-08 10:21 |只看该作者 |倒序浏览
我初学C++, 写了如下代码但编译时报错fatal error C1004: unexpected end of file found, 不知为何,请指点:

#include<iostream.h>
#include<stdio.h>


class student
{
        private:               
                int no;
        public:
                void init();
                void print();
};

class student :: init()
{       
        no = 0;
}

class student::print ()
{
        cout <<  no << endl;
}


void main()
{

        class student stu1;
        stu1.init() ;
        stu1.print();
       
}

论坛徽章:
0
2 [报告]
发表于 2006-10-08 10:24 |只看该作者
原帖由 morfast 于 2006-10-8 10:21 发表
我初学C++, 写了如下代码但编译时报错fatal error C1004: unexpected end of file found, 不知为何,请指点:

#include<iostream.h>
#include<stdio.h>


class student
{
        private:               
                int ...



#include<iostream.h>
#include<stdio.h>

using namespace std; //add this

论坛徽章:
0
3 [报告]
发表于 2006-10-08 10:27 |只看该作者
but another error appears:

error C2871: 'std' : does not exist or is not a namespace

论坛徽章:
0
4 [报告]
发表于 2006-10-08 10:29 |只看该作者
原帖由 morfast 于 2006-10-8 10:27 发表
but another error appears:

error C2871: 'std' : does not exist or is not a namespace


#include <iostream.h> 改为
#include <iostream>

没注意你这个都错了

论坛徽章:
0
5 [报告]
发表于 2006-10-08 10:33 |只看该作者
这个没错吧...省略扩展名和不省略一样

试过了...问题依旧

论坛徽章:
0
6 [报告]
发表于 2006-10-08 10:44 |只看该作者
原帖由 morfast 于 2006-10-8 10:33 发表
这个没错吧...省略扩展名和不省略一样

试过了...问题依旧

#include<iostream>
#include<stdio.h>

using namespace std;

class student
{
        private:               
                int no;
        public:
                void init();
                void print();
};

void student :: init()
{      
        no = 0;
}

void student::print ()
{
        cout <<  no << endl;
}


void main()
{

        student stu1;
        stu1.init() ;
        stu1.print();
      
}
试试,说实话真不想回答这样的问题
恐怕全世界就我愿回答你这个问题了

[ 本帖最后由 chzht001 于 2006-10-8 11:03 编辑 ]

论坛徽章:
0
7 [报告]
发表于 2006-10-08 11:22 |只看该作者

回复 5楼 morfast 的帖子

要么用
#include<iostream>
#include<stdio.h>

using namespace std;

要么用:
#include<iostream.h>
#include<stdio.h>

//using namespace std;

论坛徽章:
0
8 [报告]
发表于 2006-10-08 11:42 |只看该作者
明白了

是我太粗心了,太不好意思了

感谢楼上两位 ,很对不起, 我下次一定先核对好代码再发上来
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP