- and
- Already overloaded to process each built-in type
- Can also process a user-defined class
- Example program
- Class PhoneNumber; Holds a telephone number
- Print out formatted number automatically; (123) 456-7890
The program of Figs. 1-2 demonstrates overloading the stream-extraction and stream-insertion operators to handle data of a user-defined telephone number class called PhoneNumber.
Figure 1:
Overloaded stream-insertion and stream extraction operators. (part 1 of 2)
|
Figure 2:
Overloaded stream-insertion and stream extraction operators. (part 2 of 2)
|
2004-07-12