general question

closed account (N8RzwA7f)
this may sound like a really dumb question, but how/when if at all would one call any of the protected std library functions ? such as streambuf::eback();
or are they only called internally ? I'm trying to get a better basic understanding.
thanks.
Not a dumb question at all.

You might call the protected std library functions when you derive a class from one of the std library classes.

For example, I have a mystreambuf class that derives from streambuf. I use mystreambuf to convert stream oriented I/O to record oriented I/O on a proprietary file system. I don't use eback() since I'm dealing with output streams, but I do use the protected functions pbase() and epptr() to access the output sequence buffer. By overloading streambuf::sync(), I can get control when the stream is flushed and then convert the buffer to record oriented I/O. Any output class that I write that wants to do record oriented I/O simply passes a mystreambuf instance to an ostream constructor.
closed account (N8RzwA7f)
thanks , so how would I call a protected function. I tried using a derived pointer call :

filebuf *fb; fb->eback(); from a derived class (which inherited from streambuf).

but it did not work. I'm trying to program anything in particular now, just trying to get a better general understanding, because it all seems very vague at the moment,
thanks.
There is a small demo that calls streambuf::eback here if it helps: http://en.cppreference.com/w/cpp/io/strstreambuf/underflow#Example
Topic archived. No new replies allowed.