do_frac_digits
Defined in header <locale> | | |
---|---|---|
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。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com