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 uses the output stream's locale object (obtained via getloc()), |
//2 | uses the locale's phone number facet object, |
//3 | and calls the facet object's formatting service put(). |
OEM Edition, ©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.