
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
C++ Stream Classes Structure
In C++ stream refers to the stream of characters that are transferred between the program thread and i/o.
Stream classes in C++ are used to input and output operations on files and io devices. These classes have specific features and to handle input and output of the program.
The iostream.h library holds all the stream classes in the C++ programming language.
Let's see the hierarchy and learn about them,
Now, let’s learn about the classes of the iostream library.
ios class − This class is the base class for all stream classes. The streams can be input or output streams. This class defines members that are independent of how the templates of the class are defined.
istream Class − The istream class handles the input stream in c++ programming language. These input stream objects are used to read and interpret the input as a sequence of characters. The cin handles the input.
ostream class − The ostream class handles the output stream in c++ programming language. These output stream objects are used to write data as a sequence of characters on the screen. cout and puts handle the out streams in c++ programming language.
Example
OUT STREAM
COUT
#include <iostream> using namespace std; int main(){ cout<<"This output is printed on screen"; }
Output
This output is printed on screen
PUTS
#include <iostream> using namespace std; int main(){ puts("This output is printed using puts"); }
Output
This output is printed using puts
IN STREAM
CIN
#include <iostream> using namespace std; int main(){ int no; cout<<"Enter a number "; cin>>no; cout<<"Number entered using cin is "<
Output
Enter a number 3453 Number entered using cin is 3453
gets
#include <iostream> using namespace std; int main(){ char ch[10]; puts("Enter a character array"); gets(ch); puts("The character array entered using gets is : "); puts(ch); }
Output
Enter a character array thdgf The character array entered using gets is : thdgf
- Related Articles
- Difference between the byte stream and character stream classes in Java?
- What is a Stream and what are the types of Streams and classes in Java?
- Pseudo-classes and CSS Classes
- Character Stream vs Byte Stream in Java\n
- Pseudo-classes and all CSS Classes
- Stream In Java
- What is STREAM?
- Stream sorted() in Java
- PHP compression Stream Wrappers
- PHP Anonymous classes
- PHP Autoloading Classes
- C# Nested Classes
- Bootstrap Contextual classes
- Bootstrap Helper Classes
- Java 8 Stream Terminal Operations
