Standard library header <iostream>
From cppreference.net
此头文件是 输入/输出 库的组成部分。
包含
<iostream>
头文件的行为类似于定义了一个具有静态存储期的
std::ios_base::Init
类型对象。当该对象是首个被构造的
std::ios_base::Init
对象时,其构造函数会初始化标准流对象;当该对象是最后一个被销毁的
std::ios_base::Init
对象时,其析构函数会刷新这些流对象(不包括
cin
和
wcin
)。
包含头文件 |
||
|
(C++11)
|
std::ios_base 类、 std::basic_ios 类模板及类型定义 | |
|
(C++11)
|
std::basic_streambuf 类模板 | |
|
(C++11)
|
std::basic_istream 类模板及类型定义 | |
|
(C++11)
|
std::basic_ostream 、 std::basic_iostream 类模板及类型定义 | |
对象 |
||
|
从标准C输入流
stdin
读取
(全局对象) |
||
|
写入到标准C输出流
stdout
(全局对象) |
||
|
写入到标准C错误流
stderr
,无缓冲
(全局对象) |
||
|
写入到标准C错误流
stderr
(全局对象) |
||
概要
#include <ios> #include <streambuf> #include <istream> #include <ostream> namespace std { extern istream cin; extern ostream cout; extern ostream cerr; extern ostream clog; extern wistream wcin; extern wostream wcout; extern wostream wcerr; extern wostream wclog; }
缺陷报告
下列行为变更缺陷报告被追溯应用于先前发布的 C++ 标准。
| 缺陷报告 | 适用标准 | 发布时行为 | 正确行为 |
|---|---|---|---|
| LWG 155 | C++98 |
静态对象的类型为
std::basic_ios::Init
(并非严格错误,但表述存在误导性) |
修正为
std::ios_base::Init
|
| LWG 1123 | C++98 |
包含
<iostream>
头文件不能保证
std::ios_base::Init 对象的构造 |
确保构造 |