std::basic_streambuf<CharT,Traits>::~basic_streambuf
來自 cppreference.com
< cpp | io | basic streambuf
virtual ~basic_streambuf(); |
||
此解構函式無效果:此 basic_streambuf
的成員(指標和 locale)在此解構函式返回後,會依照通常的物件銷燬序列被銷燬。然而,因為它被宣告為 public virtual,它允許派生自 std::basic_streambuf
的物件透過基類指標被刪除。
目錄 |
[編輯] 引數
(無)
[編輯] 示例
執行此程式碼
#include <fstream> #include <iostream> int main() { std::filebuf* fbp = new std::filebuf; fbp->open("test.txt", std::ios_base::out); fbp->sputn("Hello\n", 6); std::streambuf* sbp = fbp; delete sbp; // the file is closed, output flushed and written std::ifstream f("test.txt"); std::cout << f.rdbuf(); // proof }
輸出
Hello
[編輯] 缺陷報告
下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。
缺陷報告 | 應用於 | 釋出時的行為 | 正確的行為 |
---|---|---|---|
LWG 54 | C++98 | 解構函式的效果未被指定 | 被指定為無效果 |
[編輯] 參閱
構造 basic_streambuf 物件(受保護成員函式) |