下面c++程序哪里有问题?iostream.h和iostream文件都存在

来源:百度知道 编辑:UC知道 时间:2024/06/24 01:56:14
#include<iostream.h>
#include<iostream>
using namespace std;
int main()
{cout<<"aaa";
return 0;}

#include<iostream.h>是C语言头文件的标准形式
#include<iostream>是C++语言头文件的标准形式
两个头文件编译的内容应该是没有什么差别的

C++为了于C语言兼容,许多C++编译系统保留了头文件以.h为后缀的用法

由于C语言无命名空间,因此用带后缀.h的头文件时不必用
“using namespace std;”作声明。

所以,在声明时,要么用 #include<iostream.h>
要么就用 #include<iostream>
using namespace std;

<iostream>和<iostream.h>不一样,前者没有后缀,实际上,在你的编译器include文件夹里面可以看到,二者是两个文件,打开文件就会发现,里面的代码是不一样的。
后缀为.h的头文件c++标准已经明确提出不支持了。
C里引用头文件要加.h,比如#include<stdio.h>,你把#include<iostream.h>去掉

这两个实际上是一个文件,所以不应当重复引用。
c++里,如果你写<xxx> ,会自动被编译成<xxx.h>

重复引用头文件不对。把#include<iostream.h> 去掉

是对的