在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>”成
(二)就能够运行!??