std::numpunct<CharT>::decimal_point, do_decimal_point
來自 cppreference.com
定義於標頭檔案 <locale> |
||
public: char_type decimal_point() const; |
(1) | |
protected: virtual char_type do_decimal_point() const; |
(2) | |
1) 公共成員函式,呼叫最派生類的成員函式
do_decimal_point
。2) 返回用作整數和小數部分之間小數分隔符的字元。
[編輯] 返回值
用作小數分隔符的 char_type
型別值。std::numpunct
的標準特化返回 '.' 和 L'.'。
[編輯] 示例
執行此程式碼
#include <iostream> #include <locale> struct slash : std::numpunct<char> { char do_decimal_point() const { return '/'; } // separate with slash }; int main() { std::cout.precision(10); std::cout << "default locale: " << 1234.5678 << '\n'; std::cout.imbue(std::locale(std::cout.getloc(), new slash)); std::cout << "locale with modified numpunct: " << 1234.5678 << '\n'; }
輸出
default locale: 1234.5678 locale with modified numpunct: 1234/5678