What is C++ Standard Output Stream (cout)?

std::cout is an object of class ostream that represents the standard output stream oriented to narrow characters (of type char). It corresponds to the C stream stdout. The standard output stream is the default destination of characters determined by the environment. This destination may be shared with more standard objects (such as cerr or clog).

As an object of class ostream, characters can be written to it either as formatted data using the insertion operator (operator<<) or as unformatted data, using member functions such as write. The object is declared in the header <iostream> with external linkage and static duration: it lasts the entire duration of the program.

You can use this object to write to the screen. For example, if you want to write "Hello" to the screen, you'd write −


Live Demo

int main() {
   std::cout << "Hello";
   return 0;

Then save this program to hello.cpp file. Finally navigate to the saved location of this file in the terminal/cmd and compile it using −

$ g++ hello.cpp

Run it using −

$ ./a.out


This will give the output −


Rishi Raj
Rishi Raj

I am a coder

Updated on: 10-Feb-2020

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started