标准库头文件 <iostream>
来自 cppreference.cn
此头文件是 Input/output 库的一部分。
包含 <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 对象的构造 |
保证 |