std::basic_ostream<CharT,Traits>::~basic_ostream
來自 cppreference.com
< cpp | io | basic_ostream
virtual ~basic_ostream(); |
||
銷燬 basic_ostream
物件。此解構函式不對底層 streambuffer (rdbuf()
) 執行任何操作:std::basic_ofstream 和 std::basic_ostringstream 等派生輸出流的解構函式負責呼叫流緩衝區的解構函式。
[編輯] 示例
執行此程式碼
#include <iostream> #include <sstream> void add_words(std::streambuf* p) { std::ostream buf(p); // buf shares the buffer with s buf << " is the answer"; } // calls the destructor of buf. p remains unaffected int main() { std::ostringstream s; s << 42; add_words(s.rdbuf()); s << "."; std::cout << s.str() << '\n'; }
輸出
42 is the answer.