money_put::put
将数字或字符串转换为一个表示货币值的字符序列。
iter_type put(
iter_type _Next,
bool _Intl,
ios_base& _Iosbase,
CharType _Fill,
const string_type& _Val
) const;
iter_type put(
iter_type _Next,
bool _Intl,
ios_base& _Iosbase,
CharType _Fill,
long double _Val
) const;
参数
_Next
解决的迭代器插入的字符串的第一个元素。_Intl
指示货币符号的类型布尔值应在序列: true,如果国际,false,如果国内。_Iosbase
格式标志,当设置指示货币符号是可选的;否则,需要_Fill
为了节省空间使用的字符。_Val
将转换的字符串对象。
返回值
输出迭代器在最后一个元素之外的位置都产生的地址。
备注
两个成员函数返回 do_put(_Next、_Intl、_Iosbase、_Fill,_Val)。
示例
// money_put_put.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
using namespace std;
int main( )
{
// locale loc( "german_germany" );
locale loc( "english_canada" );
basic_stringstream<char> psz, psz2;
ios_base::iostate st = 0;
psz2.imbue( loc );
psz2.flags( psz2.flags( )|ios_base::showbase ); // force the printing of the currency symbol
use_facet < money_put < char > >(loc).put(basic_ostream<char>::_Iter( psz2.rdbuf( ) ), true, psz2, st, 100012);
if (st & ios_base::failbit)
cout << "money_put( ) FAILED" << endl;
else
cout << "money_put( ) = \"" << psz2.rdbuf( )->str( ) <<"\""<< endl;
st = 0;
};
要求
标头: <locale>
命名空间: std