Lecture 3 - Slide 21 : 27
More manipulators
Manipulators can be with or without arguments
Manipulators without arguments
The manipulator is a
pointer to function
Handled by an operator overload of
operator<<
on
basic_ostream<C,Tr>
See example below
Manipulators with arguments
The manipulator
m(a)
returns an struct that aggregates a function pointer and the argument
a
An overload of
<<
activates the function on the argument before it returns the stream
Interesting details on page 1087 in
The C++ Prog. Lang. (4. edition)
Illustrated below in an example
Illustration of more manipulators.
Program output.
Programming our own manipulator - with two parameters.
Program output.
Understand the way we program and use output stream manipulators