ostream_iterator

Line 19 creates an ostream_iterator that’s capable of inserting (outputting) int values in the standard output object cout. Line 22 outputs an integer to cout by assigning to *outputInt the sum of number1 and number2. Notice that we use the dereferenced outputInt iterator as an lvalue in the assignment statement. If you want to output another value using outputInt, the iterator must be incremented with ++ first. Either the prefix or postfix increment can be used—we use the prefix form for performance reasons because it does not create a temporary object.


Image Error-Prevention Tip 15.2

The * (dereferencing) operator when applied to a const iterator returns a reference to const for the container element, disallowing the use of non-const member functions.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.216.12