名稱空間
變體
操作

標準庫標頭檔案 <iostream>

來自 cppreference.com
 
 
標準庫標頭檔案
演算法
<algorithm>
<numeric>
字串
<cctype>
<cstring>
<cuchar> (C++11)
<cwchar>
<cwctype>
<string_view> (C++17)
<string>
文字處理
<clocale>
<codecvt> (C++11/17/26*)
<locale>
<regex> (C++11)
<text_encoding> (C++26)   
數值
<cfenv> (C++11)
<cmath>
<complex>
<linalg> (C++26)
<numbers> (C++20)
<random> (C++11)
<simd> (C++26)
<valarray>
時間
<chrono> (C++11)
<ctime>
C 相容性
<ccomplex> (C++11/17/20*)
<ciso646> (until C++20)
<cstdalign> (C++11/17/20*)
<cstdbool> (C++11/17/20*)
<ctgmath> (C++11/17/20*)
 

此標頭檔案是 Input/output 庫的一部分。

包含 <iostream> 的行為如同它定義了一個 std::ios_base::Init 型別的靜態儲存期物件,該物件的建構函式會在它是第一個被構造的 std::ios_base::Init 物件時初始化標準流物件,其解構函式則會在它是最後一個被銷燬的 std::ios_base::Init 物件時重新整理這些物件(除了 cinwcin)。

目錄

包含

(C++11)
std::ios_base 類,std::basic_ios 類模板和型別定義[編輯]
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 物件的構造
保證