标题:在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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-324635-1-1.html




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

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