Hi, im just beginning c++ and been reading regarding cin and cout. After reading the chapter, I just got curious what acually a stream is. It is said in some as a series of characters. In this site:
"A stream is an abstraction that represents a device on which input and ouput operations are performed. A stream can basically be represented as a source or destination of characters of indefinite length."
Represents a device? Does that mean a stream can come from or is an abstraction if an IO device (mouse, trackball, printer, etc). Please help me get this cleared up.
If you are a UNIX person, think of a stream as the C++ abstraction of a file descriptor. A stream allows you to read and write data from/to the source in much the same way as fread and fwrite work in C-land.
In UNIX, many devices are presented to the user as special inodes in /dev. For example, you can play sound by opening a file descriptor to /dev/dsp or /dev/sound. It just depends on whether or not the device supports a file descriptor API. In UNIX, this is the standard model. In "other" OSes, I don't know.
So, the more I read it, the more it says what it is:
... A stream can basically be represented as a source or destination of characters of indefinite length."
Thanks for the reply. I did some researching and you were right about the abstraction of devices as a source and destination. BTW, I use Windows but your definition is conceptually the same to the one I've read. Thanks again!