An application that has to handle phone numbers will probably have a class that represents a phone number. We will also want to read and write telephone numbers via iostreams, and therefore define suitable extractor and inserter functions. For the sake of simplicity, we will focus on the inserter function in our example.
To begin, here is the complete class declaration for the telephone number class PhoneNumber:
struct PhoneNumber { typedef std::string string_type; PhoneNumber (const string_type cntryName, const string_type areaCode, const string_type extension) : _cntryName (cntryName), _areaCode (areaCode), _extension (extension) {} string_type _cntryName; // "US" string_type _areaCode; // "303" string_type _extension; // "545-3200" };