标准库头文件 <iostream>
来自 cppreference.cn
此头文件是 输入/输出 库的一部分。
包含 <iostream>
的行为就像它定义了一个类型为 std::ios_base::Init 的静态存储期对象,如果它是第一个被构造的 std::ios_base::Init
对象,则其构造函数初始化标准流对象,并且如果它是最后一个被销毁的 std::ios_base::Init
对象,则其析构函数刷新这些对象(cin
和 wcin
除外)。
包括 | ||
(C++11) |
std::ios_base 类,std::basic_ios 类模板和 typedefs | |
(C++11) |
std::basic_streambuf 类模板 | |
(C++11) |
std::basic_istream 类模板和 typedefs | |
(C++11) |
std::basic_ostream, std::basic_iostream 类模板和 typedefs | |
对象 | ||
从标准 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++ 标准。
DR | 应用于 | 已发布行为 | 正确行为 |
---|---|---|---|
LWG 155 | C++98 | 静态对象的类型是 std::basic_ios::Init (不严格错误,但措辞具有误导性) |
更正为 std::ios_base::Init |
LWG 1123 | C++98 | 包含 <iostream> 不保证std::ios_base::Init 对象的构造 |
保证 |