| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 448 人关注过本帖
标题:关于头文件的一个小问题,高手进来下…………
只看楼主 加入收藏
a632034079
Rank: 2
等 级:论坛游民
帖 子:115
专家分:34
注 册:2009-10-3
结帖率:86.11%
收藏
已结贴  问题点数:20 回复次数:4 
关于头文件的一个小问题,高手进来下…………
为什么下面的代码用#include <iostream> using namespace std;就不不能通过编译,而用#include <iostream.h>却可以???这两个头文件的不是同样的意思吗???他们有什么区别吗???


include <iostream.h>

class shijian
{
private:
public:
    int year;
    int month;
    int day;
public:
    friend ostream& operator<<(ostream& output,shijian &sj);
    friend istream& operator>>(istream& input,shijian &x);
};

ostream& operator<<(ostream &output,shijian &sj)
{
    output << sj.year << "/" << sj.month << "/" << sj.day << endl;
    return output;
}

istream& operator>>(istream& input,shijian &x)
{
    input >> x.year >> x.month >> x.day;
    return input;
}

int main()
{
    shijian a;
    cin>>a;
    cout<<a;

    return 0;;
}
搜索更多相关主题的帖子: 文件 
2010-08-10 11:24
towhee
Rank: 2
来 自:石家庄火车站
等 级:论坛游民
威 望:1
帖 子:48
专家分:69
注 册:2010-8-8
收藏
得分:7 
程序代码:
#include <iostream>
using namespace std;
class shijian
{
private:
public:
    int year;
    int month;
    int day;
public:
    friend ostream& operator<<(ostream& output,shijian &sj);
    friend istream& operator>>(istream& input,shijian &x);
};

ostream& operator<<(ostream &output,shijian &sj)
{
    output << sj.year << "/" << sj.month << "/" << sj.day << endl;
    return output;
}

istream& operator>>(istream& input,shijian &x)
{
    input >> x.year >> x.month >> x.day;
    return input;
}

int main()
{
    shijian a;
    cin>>a;
    cout<<a;

    return 0;;
}

以上代码编译通过,环境vs2005+xp

最穷无非讨饭,不死终会出头
2010-08-10 17:38
towhee
Rank: 2
来 自:石家庄火车站
等 级:论坛游民
威 望:1
帖 子:48
专家分:69
注 册:2010-8-8
收藏
得分:0 
程序代码:
#include <iostream>
using namespace std;
class shijian
{
private:
public:
    int year;
    int month;
    int day;
public:
    friend ostream& operator<<(ostream& output,shijian &sj);
    friend istream& operator>>(istream& input,shijian &x);
};

ostream& operator<<(ostream &output,shijian &sj)
{
    output << sj.year << "/" << sj.month << "/" << sj.day << endl;
    return output;
}

istream& operator>>(istream& input,shijian &x)
{
    input >> x.year >> x.month >> x.day;
    return input;
}

int main()
{
    shijian a;
    cin>>a;
    cout<<a;

    return 0;;
}

以上代码编译通过,环境vs2005+xp

最穷无非讨饭,不死终会出头
2010-08-10 18:10
a632034079
Rank: 2
等 级:论坛游民
帖 子:115
专家分:34
注 册:2009-10-3
收藏
得分:0 
以下是引用towhee在2010-8-10 18:10:22的发言:


#include <iostream>
using namespace std;
class shijian
{
private:
public:
    int year;
    int month;
    int day;
public:
    friend ostream& operator<<(ostream& output,shijian &sj);
    friend istream& operator>>(istream& input,shijian &x);
};

ostream& operator<<(ostream &output,shijian &sj)
{
    output << sj.year << "/" << sj.month << "/" << sj.day << endl;
    return output;
}

istream& operator>>(istream& input,shijian &x)
{
    input >> x.year >> x.month >> x.day;
    return input;
}

int main()
{
    shijian a;
    cin>>a;
    cout<<a;

    return 0;;
}

以上代码编译通过,环境vs2005+xp



VC++6.0不能通过………………
2010-08-11 07:32
pangding
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:北京
等 级:贵宾
威 望:94
帖 子:6784
专家分:16751
注 册:2008-12-20
收藏
得分:7 
编译报的错是什么?
2010-08-11 09:39
快速回复:关于头文件的一个小问题,高手进来下…………
数据加载中...
 
   



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

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