std::moneypunct::frac_digits
STD::货币区::[医]数字,做[医]框架c[医]位数
Defined in header | | |
---|---|---|
public: int frac_digits() const; | (1) | |
protected: virtual int do_frac_digits() const; | (2) | |
1%29公共成员函数,调用成员函数do_frac_digits
最派生的类。
2%29在打印货币值时返回小数点后要显示的数字数。
返回值
小数点之后要显示的数字数。在常见的美国地区,这是2
...
例
二次
#include <locale>
#include <iostream>
#include <iomanip>
#include <iterator>
struct space_out : std::moneypunct<char> {
pattern do_pos_format() const { return { {value, none, none, none} };}
int do_frac_digits() const { return 0; }
char_type do_thousands_sep() const { return ' ';}
string_type do_grouping() const { return "\002";}
};
int main()
{
std::cout.imbue(std::locale("en_US.UTF-8")
std::cout << "american locale: " << std::showbase
<< std::put_money(12345678.0)<< '\n';
std::cout.imbue(std::locale(std::cout.getloc(), new space_out)
std::cout << "locale with modified moneypunct: "
<< std::put_money(12345678.0)<< '\n';
}
二次
产出:
二次
american locale: $123,456.78
locale with modified moneypunct: 12 34 56 78
二次
另见
do_thousands_sep virtual | provides the character to use as thousands separator (virtual protected member function) |
---|---|
do_decimal_point virtual | provides the character to use as decimal point (virtual protected member function) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
http://en.cppreference.com/w/cpp/locale/monyypunct/frac[医]位数