|
|
There are two operations which permit output to ostreams
from
List<T>
s and List_of_p<T>
s.
Not everyone who uses List<T>
s will want
to use these output operations.
In fact, if T::operator<<()
is not defined, these operators will not work!
Xout << L
sends a copy of List
L
to ostream Xout
and returns Xout
.
The format is as follows: a left
parenthesis is placed on the stream,
followed by the space-separated members of the
List (which are placed on the stream by T::operator<<()
),
followed by a right parenthesis.
Xout << Lp
sends a copy of List_of_p
Lp
to ostream
Xout
and returns Xout
.
The format is as follows: a left parenthesis
is placed on the stream, followed by
the space-separated dereferenced members
(since the List holds pointers to Ts) of
the List (which are placed on the stream by T::operator<<()
),
followed by a right parenthesis.
These operations are rather simplistic. You can write customized output functions for your own List types using techniques described in the ``Example'' section.