virtual int overflow( int nCh = EOF ) = 0;
nCh
EOF or the character to output.
The virtual overflow function, together with the sync and underflow functions, defines the characteristics of the streambuf-derived class. Each derived class might implement overflow differently, but the interface with the calling stream class is the same.
The overflow function is most frequently called by public streambuf functions like sputc and sputn when they sense that the put area is full, but other classes, including the stream classes, can call overflow anytime.
The function “consumes” the characters in the put area between the pbase and pptr pointers and then reinitializes the put area. The overflow function must also consume nCh (if nCh is not EOF), or it might choose to put that character in the new put area so that it will be consumed on the next call.
The definition of “consume” varies among derived classes. The filebuf class, for example, writes its characters to a file. The strsteambuf class, on the other hand, keeps them in its buffer and (if the buffer is designated as dynamic) expands the buffer in response to a call to overflow. This expansion is achieved by freeing the old buffer and replacing it with a new, larger one. The pointers are adjusted as necessary.
No default implementation. Derived classes must define this function.
EOF to indicate an error.
streambuf::pbase, streambuf::pptr, streambuf::setp, streambuf::sync, streambuf::underflow