
Now let's take a look at the implementation of the inserter for our phone number class:
ostream& operator<<(ostream& os, const phoneNo& pn)
{
locale loc = os.getloc(); //1
const phone_put& ppFacet = use_facet<phone_put> (loc); //2
os << ppFacet.put(pn.extension, pn.areaCode, pn.countryCode);//3
return (os);
}
| //1 | The inserter function will use the output stream's locale object (obtained via getloc()), |
| //2 | use the locale's phone number facet object, |
| //3 | and call the facet object's formatting service put(). |
©Copyright 1998, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.