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 phoneNo:
class phoneNo { public: typedef basic_ostream<char> outStream_t; typedef string string_t; phoneNo(const string_t& cc,const string_t& ac,const string_t& ex) : countryCode(cc), areaCode(ac), extension(ex) {} private: string_t countryCode; //"de" string_t areaCode; //"89" string_t extension; //"636-48018" friend phoneNo::outStream_t& operator<< (phoneNo::outStream_t&, const phoneNo&); };
OEM Edition, ©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.