C++ iostream和iostream.h的区别
2021/12/23 20:07:50
本文主要是介绍C++ iostream和iostream.h的区别,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
#include <iostream.h>非标准输入输出流
#include 标准输入输出流
C++中为了避免名字定义冲突,特别引入了“名字空间的定义”,即namespace。
当代码中用<iostream.h>时,输出可直接引用cout<<x;//<iostream.h>继承C语言的标准库文件,未引入名字空间定义,所以可直接使用。
当代码中引入时,输出需要引用std::cout<<x;如果还是按原来的方法就会有错。
iostream.h是input output stream的简写,意思为标准的输入输出流头文件。它包含:
(1)cin>>“要输入的内容”
(2)cout<<“要输出的内容”
这两个输入输出的方法需要#include头文件来声明。
iostream 库的基础是两种命名为 istream 和 ostream 的类型,分别表示输入流和输出流。流是指要从某种 IO 设备上读出或写入的字符序列。
iostream和iostream.h的用法
使用和命名空间
#include
using namespace std;
int main()
{
cout<<" need to use namespace std!/n";
return 0;
}
输出:
need to use namespace std!
Press any key to continue
使用<iostream.h>,不引入命名空间
#include <iostream.h>
//using namespace std;
int main()
{
cout<<" need to use namespace std!/n";
return 0;
}
输出:
need to use namespace std!
Press any key to continue
这篇关于C++ iostream和iostream.h的区别的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-04el-table 开启定时器下,表格的选中状态会消失是什么原因-icode9专业技术文章分享
- 2024-10-03如何安装和初始化飞牛私有云 fnOS?-icode9专业技术文章分享
- 2024-10-03如何安装 App 并连接到飞牛 NAS?-icode9专业技术文章分享
- 2024-10-03如何安装飞牛 TV 并连接到影视服务器?-icode9专业技术文章分享
- 2024-10-03如何在PVE和ESXI上安装飞牛私有云 fnOS?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS安装系统异常情况处理-icode9专业技术文章分享
- 2024-10-03飞牛NAS如何创建存储空间?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS硬盘会自动休眠吗?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS如何安装飞牛影视和创建媒体库?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS如何为家人朋友开通影视账号?-icode9专业技术文章分享