命名空间
变体
操作

std::moneypunct<CharT,International>::decimal_point,do_decimal_point

来自 cppreference.cn
< cpp‎ | locale‎ | moneypunct
 
 
 
 
 
定义于头文件 <locale>
public:
CharT decimal_point() const;
(1)
protected:
virtual CharT do_decimal_point() const;
(2)
1) 公有成员函数,调用最派生类的成员函数 do_decimal_point
2) 返回在货币 I/O 中用作小数点分隔符的字符,如果格式使用小数(即,如果 do_frac_digits() 大于零)。对于典型的美国区域设置,它是字符 '.' (或 L'.')。

[编辑] 返回值

类型为 CharT 的对象,持有小数点字符。

[编辑] 示例

#include <iomanip>
#include <iostream>
#include <locale>
 
void show_dpt(const char* locname)
{
    std::locale loc(locname);
    std::cout.imbue(loc);
    std::cout << locname << " decimal point is '"
              << std::use_facet<std::moneypunct<char>>(loc).decimal_point()
              << "' for example: " << std::showbase << std::put_money(123);
    if (std::use_facet<std::moneypunct<char>>(loc).frac_digits() == 0)
        std::cout << " (does not use frac digits)";
 
    std::cout << '\n';
}
 
int main()
{
    show_dpt("en_US.utf8");
    show_dpt("ja_JP.utf8");
    show_dpt("sv_SE.utf8");
    show_dpt("de_DE.utf8");
}

输出

en_US.utf8 decimal point is '.' for example: $1.23
ja_JP.utf8 decimal point is '.' for example: ¥123 (does not use frac digits)
sv_SE.utf8 decimal point is ',' for example: 1,23 kr
de_DE.utf8 decimal point is ',' for example: 1,23 €

[编辑] 参见

[虚函数]
提供要显示在小数点后的位数
(虚保护成员函数) [编辑]