locale::global
Resets the default locale for the program. This affects the global locale for both C and C++.
static locale global(
const locale& _Loc
);
매개 변수
- _Loc
The locale to be used as the default locale by the program.
반환 값
The previous locale before the default locale was reset.
설명
At program startup, the global locale is the same as the classic locale. The global() function calls setlocale( LC_ALL, loc.name. c_str()) to establish a matching locale in the Standard C library.
예제
// locale_global.cpp
// compile by using: /EHsc
#include <locale>
#include <iostream>
#include <tchar.h>
using namespace std;
int main( )
{
locale loc ( "German_germany" );
locale loc1;
cout << "The initial locale is: " << loc1.name( ) << endl;
locale loc2 = locale::global ( loc );
locale loc3;
cout << "The current locale is: " << loc3.name( ) << endl;
cout << "The previous locale was: " << loc2.name( ) << endl;
}
요구 사항
Header: <locale>
네임스페이스: std