... parts of the telephone number into the areaCode (line 22), exchange (line 24) and line (line 26) data members of the PhoneNumber object referenced by parameter number—the function is a friend of the class, so it can access a PhoneNumber’s private members. Stream manipulator setw limits the number of characters read into each string. When used with cin and strings, setw restricts the number of characters read to the number of characters specified by its argument (i.e., setw(3) allows three characters to be read). The parentheses, space and dash characters are skipped by calling istream member function ignore (Fig. 10.4, lines 21, 23 and 25), which discards the specified number of characters in the input stream (one character by default).

Function ...

Get C++ How to Program, 10/e now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.