#include #include #include //for locale #include //for runtime_error #include //for ostringstream using namespace std; int main() { const locale loc1 = cout.getloc(); //copy the locale of cout cout << "cout's locale is \"" << loc1.name() << "\".\n"; const locale loc2(""); //the user's preferred locale const locale loc3 = locale::classic(); //static member function const locale loc4; //global locale try { const locale loc5("fr_CA"); cout << "The French Canadian locale is \"" << loc5.name() << "\".\n"; locale::global(loc5); //static member function cout << "The new global locale is \"" << locale().name() << "\".\n"; } catch (const runtime_error& e) { cerr << e.what() << "\n"; } ostringstream ost; const locale loc6 = ost.getloc(); cout << "The locale of a new stream is \"" << loc6.name() << "\".\n"; if (loc6 == locale()) { cout << "ost's locale is the same as the global one.\n"; } return EXIT_SUCCESS; }