basic_ostream Class

這個樣板類別描述物件來控制插入項目和已編碼的物件型別的項目與資料流緩衝區 Elem,也就是 char_type,其字元特性由類別 Tr,也就是 traits_type

template <class _Elem, class _Tr = char_traits<Elem> >
   class basic_ostream
       : virtual public basic_ios<_Elem, _Tr>

參數

  • _Elem
    char_type

  • _Tr
    字元traits_type

備註

大部分的成員函式該多載運算子 << 是格式化的輸出函式。 它們會遵循的模式:

   iostate state = goodbit;
   const sentry ok( *this );
   if ( ok )
      {try
         {<convert and insert elements
         accumulate flags in state> }
      catch ( ... )
         {try
           {setstate( badbit ); }
         catch ( ... )
           {}
         if ( ( exceptions( ) & badbit ) != 0 )
           throw; }}
   width( 0 );    // Except for operator<<(Elem)
   setstate( state );
   return ( *this );

其他兩個成員函式都是未格式化的輸出函式。 它們會遵循的模式:

   iostate state = goodbit;
   const sentry ok( *this );
   if ( !ok )
      state |= badbit;
   else
      {try
         {<obtain and insert elements
         accumulate flags in state> }
      catch ( ... )
         {try
            {setstate( badbit ); }
         catch ( ... )
            {}
         if ( ( exceptions( ) & badbit ) != 0 )
            throw; }}
   setstate( state );
   return ( *this );

這兩個群組的函式呼叫的 setstate(badbit) 如果他們在插入項目時所遇到失敗。

物件的類別 basic_istream <ElemTr> 會儲存只有虛擬公用基底物件類別的 basic_ios< ElemTr >

範例

請參閱範例的basic_ofstream Class若要進一步瞭解輸出資料流。

5cf30x1h.collapse_all(zh-tw,VS.110).gif建構函式

basic_ostream

建構 basic_ostream 物件。

5cf30x1h.collapse_all(zh-tw,VS.110).gif成員函式

排清

清除緩衝區。

放入

將資料流中的字元。

seekp

重設輸出資料流中的位置。

哨兵

巢狀的類別會描述其宣告結構的格式化的輸出函式和未格式化的輸出函式的物件。

交換

交換的值basic_ostream物件所提供的basic_ostream物件。

tellp

在報表中的位置輸出資料流。

write

將資料流中的字元。

5cf30x1h.collapse_all(zh-tw,VS.110).gif運算子

operator=

提供的值指定basic_ostream物件到這個物件的參數。

運算子 <<

寫入資料流。

需求

標頭: <ostream>

Namespace: 標準

請參閱

參考

在標準 C++ 程式庫中的執行緒安全

iostream 程式設計

iostreams 慣例

其他資源

basic_ostream 成員

<ostream> 成員