![]() |
VOOZH | about |
Stream classes form the foundation for handling input or output (I/O) operations. They provide a clean and efficient way to read data from sources like the keyboard or files and write data to destinations like the screen or files.
The stream classes are organized in a class hierarchy ( a family tree of classes). This helps the language handle different types of input/output operations using common features, while still supporting special cases like file I/O.
At the top of this hierarchy is the ios class, which serves as the base class for other key stream classes:
It is the topmost base class that provides essential input or output facilities to all other stream classes. It manages shared properties such as formatting and error states.
It is responsible for input operations. It provides functions for reading characters, strings, and objects such as:
Example:
Input:
gIt is responsible for output operations. It provides functions to write characters, strings, and objects, such as:
Example:
Input:
gOutput:
gIt inherits from both istream and ostream, making it capable of handling both input and output operations. It supports all functions from istream and ostream.
Example:
geeks
The stream library also provides _withassign versions of the input and output stream classes. These variants allow objects to be assigned and reassigned at runtime.
4 5Output:
Enter two numbers dx and dy
4 5
dx=4 dy=5
Example:
Value of dx and dy are 4 5