
Now that we have laid the groundwork, we are almost ready to format phone numbers. Here is an example of how instances of the new facet class can be used:
using std::cout;
using std::endl;
using std::locale;
cout.imbue (locale (locale::classic (), new US_phone_put)); //1
cout << PhoneNumber ("Fr", "1", "60 17 07 16") << endl;
cout << PhoneNumber ("US", "303", "545-3200") << endl;
cout.imbue (locale (locale ("Fr"),
new Fr_phone_put (&myCountryCodes))); //2
cout << PhoneNumber ("Allemagne", "89", "636-40938") << endl; //3
| //1 | Imbue an output stream with a locale object that has a phone number facet object. In the example above, it is the US English ASCII locale with a US phone number facet, and | |||
| //2 | A French locale using a French phone number facet with a particular country code table. | |||
| //3 | Output phone numbers using the inserter function. The output is:
|
Copyright (c) 1994-2006 Rogue Wave Software, a Quovadx Division.
Licensed under the Apache License, Version 2.0.
Contact Rogue Wave about documentation or support issues. You can also seek help from other developers through the Apache stdcxx community (see below).