| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 6478 人关注过本帖
标题:在C++编程里,什么时候用“#include<iostream> using namespace std;”?什 ...
取消只看楼主 加入收藏
bc574479449
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2010-10-18
结帖率:100%
收藏
已结贴  问题点数:0 回复次数:1 
在C++编程里,什么时候用“#include<iostream> using namespace std;”?什么时候又用“#include <
(一)、#include <iostream.h>
using namespace std;
class point
{
public:point(int x1=0,int y1=0):x(x1),y(y1){}
       friend ostream& operator<<(ostream&, const point&);
      
       friend istream& operator>>(istream&,point&);
       int x,y;     
};
ostream& operator<<(ostream& out, point& src)
{
    out<<"<"<<src.x<<","<<src.y<<">";
    return out;
}
istream& operator>>(istream& in,point& target)
{
    in>>target.x>>target.y;
    return in;
}
int main()
{
    point a(1,2);
    cin>>a;
    cout<<a;
    return 0;
}
(二)、#include <iostream.h>
class point
{
    int x,y;
public:
    point(int x1=0,int y1=0):x(x1),y(y1){}      
    friend ostream& operator<<(ostream&, const point&);     
    friend istream& operator>>(istream&, point&);
};
ostream& operator<<(ostream& out, const point& src)
{
    out << "<" << src.x << "," << src.y << ">";
    return out;
}

istream& operator>>(istream& in,point& target)
{
    in>> target.x >> target.y;
    return in;
}
int main()
{
    point a(1,2);
    cin>>a;
    cout<<a;
    return 0;
}
为什么换个头文件“#include <iostream.h>”成
(二)就能够运行!??
搜索更多相关主题的帖子: std using include iostream 
2010-11-01 14:25
bc574479449
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2010-10-18
收藏
得分:0 
在C++编程里,什么时候用“#include<iostream> using namespace std;”?什么时候又用“#include <iostream.h>”?
2010-11-01 14:26
快速回复:在C++编程里,什么时候用“#include<iostream> using namespace std;” ...
数据加载中...
 
   



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

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