iostream.h iostream 区别

来源:百度知道 编辑:UC知道 时间:2024/05/30 09:54:05
#include<iostream>
#include<iterator>
#include<algorithm>
#include<vector>
using namespace std;

void main()
{
istream_iterator<int> INPUT(cin);
istream_iterator<int> end;
vector<int> v;
copy(INPUT,end,inserter(v,v.begin()));
ostream_iterator<int> OUTPUT(cout," ");
unique_copy(v.begin(),v.end(),OUTPUT);
}
为什么#include<iostream>换成#include<iostream.h>就错了
但是如果只有iostream.h,没有using namespace std;也错啊?
是不是
#include<iterator>
#include<algorithm>
#include<vector>
要用到using namespace std;啊???
我知道
#include<iostream.h>
或者是
#include<iostream>
using namespace std;
二者都行,但是这个程序好像不是啊?

但是为什么我以前写的程序都是可以互换的啊~这个为什么特殊呢?

你用了using namespace std;后 就不用后面的.h了!!
这句是说明你用了标准的命名空间!

或者是
#include<iostream.h>
或者是
#include<iostream>
using namespace std;
二者都行,要是混着用就错了

#include<iostream.h>是C语言中比较通用的
#include<iostream>
using namespace std;
是C++中比较通用的

iostream.h你使用的函数库中没有这个文件,所以报错,vs2005、MinGW环境下默认都没有这个文件。iostream是标准c++中定义的头文件定义方式为了区别原来的c的头文件。原来c的头文件去掉.h后缀在原来文件名前加c。例如cmath等。不过现在都还保留着原来的c的头文件。std是标准c++中使用一个命名空间。你也可以这么使用std::cout,效果是一样的。