Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In the IO streams' design, most of the actual streams' functionality (as opposed to the stream buffers' functionality) is implemented in <code>std::basic_istream</code>, <code>std::basic_ostream</code>, and their base classes. <em>The string and file stream classes are more or less just convenience wrappers which make sure a stream with the right type of buffer is instantiated</em>. </p> <p>If you want to extend the streams, <em>you almost always want to provide your <strong>own stream buffer class</em></strong>, and you almost never need to provide your own stream class. . </p> <p>Once you have your own stream buffer type, you can then make it the buffer for any stream object you happen to have around. Or you derive your own classes from <code>std::basic_istream</code>, <code>std::basic_ostream</code>, and <code>std::basic_iostream</code> which instantiates your stream buffer and pass it to their base classes.<br> The latter is more convenient for users, but requires you to write some boiler-plate code for the buffer's instantiation (namely constructors for the stream class). </p> <p>To answer your question: File streams and file buffer are coupled so tightly because the former only exists to ease the creation of the latter. Using a file stream makes it easy to set it all up.<br> Using your own stream class to wrap construction of your own stream buffer shouldn't be a problem, since you shouldn't be passing around file streams anyway, but only (references) to the base classes. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload