iostream与iostream.h有区别吗?
如果写成这样的话就有输出结果
#include <iostream>#include <windows.h>using namespace std;int main(){ POINT p; //定义一个点 while (true) { if (GetCursorPos(&p)) { cout << "当前鼠标位置:" << p.x << "," << p.y; Sleep(500); system("cls"); } }}#include <iostream.h>#include <windows.h>int main(){ POINT p; //定义一个点 while (true) { if (GetCursorPos(&p)) { cout << "当前鼠标位置:" << p.x << "," << p.y; Sleep(500); system("cls"); } }}cout << "当前鼠标位置:" << p.x << "," << p.y << endl;
[解决办法]
#include<iostream> // 这个就是1998年标准化以后的标准头文件,样写,里面的函数都是全局函数.
#include<iostream.h> // 这个就是标准化以前的头文件
iostream是现在C++中规定的标准,目的在于使C++代码用于移植和混合嵌入时不受扩展名.h的限制,避免因为.h而造成的额外的处理和修改。iostream包含的基本功能和对应的旧头文件相同,但头文件的内容在名字空间std中。(在标准化的过程中,库中有些部分的细节被修改了,所以旧头文件和新头文件中的实体不一定完全对应。) 一般情况下应该用这个头文件,而iostream.h则是老式的,以后有可能被淘汰。
C++中新定义的方法都是有名字空间的 比如cout就属于std名字空间 如果include头文件的时候加上.h,默认会using namespace 否则需要自己加上 using namespace XXX 对于C中已经定义的方法如printf,没有影响的
iostream.h是包含输入/输出流处理的头文件,iostream就什么都不是了
但用iostream要加名词空间namespace
#include<iostream.h>
或者是
#include<iostream>
using namespace std;
二者都行
#include<iostream.h>是C语言中比较通用的
#include<iostream>
using namespace std;
是C++中比较通用的
[解决办法]
http://blog.csdn.net/hairetz/archive/2009/05/14/4184385.aspx
以前转的。
[解决办法]
不用h就对了
[解决办法]
估计.和是老的,要刷新一下,即<<endl;
[解决办法]
std 问题