October 2011
Beginner to intermediate
1200 pages
35h 33m
English
ostream MethodsBesides the various operator<<() functions, the ostream class provides the put() method for displaying characters and the write() method for displaying strings.
Originally, the put() method had the following prototype:
ostream & put(char);
The current standard is equivalent, except it’s templated to allow for wchar_t. You invoke it by using the usual class method notation:
cout.put('W'); // display the W character
Here cout is the invoking object and put() is the class member function. Like the << operator functions, this function returns a reference to the invoking object, so you can concatenate output with it:
cout.put('I').put('t'); // displaying It with two put() calls
The function call cout.put('I') returns ...
Read now
Unlock full access