The Actor 4 example begins where the Actor 3 example ends. As illustrated in the following UML class diagram, Actor 4 adds an overloaded inserter operator (operator<<) to each of the Actor 3 classes. The inserter serves the same purpose as the display function, and a "real" program would typically have one or the other but not both.
UML class diagrams are language agnostic (3), and so language-specific syntax, like pass and return by reference, is typically not included in the diagrams. Nevertheless, I have included the reference notation in the Actor example to clarify and reinforce some of the patterns that help us overload the inserter operator for any class. As you study the following examples, look for these elements. The inserter always:
is a friend function
is overloaded for a specific class
returns output stream by reference: ostream&
has an output stream reference as its first parameter, but programmers may choose the name: ostream& out
has a reference to the defining class as its second parameter, and programmers may choose an appropriate name: Date& me, etc.
ends by returning its first parameter: return out
All the inserters in the Actor example are very sort. So, each function is implemented inside its respective class. Place these function inside the Actor 3 class specifications to create the complete, final classes.