As mentioned earlier, the virtual function in the base class facet do_put() must be overridden in derived classes to actually implement locale dependent formatting of phone numbers. In the example below, we show do_put() (see //1) being overridden in the derived facet class US_phone_put to implement formatting phone numbers in the US style. This overridden version will be called by the base class's put() member function
class US_phone_put: public phone_put { ... protected: ... // perform formatting in the US style virtual string_type do_put(string_type cntryName, //1 string_type areaCode, string_type extension) const { ... } };
For the sake of brevity, we spare you here the details of the actual implementation of the formatting in do_put().