Output using cout





Output using cout

  cout <<"Welcome to this course\n";

  • The identifier cout (pronounced “C out”) is actually an object. It is predefined in C++ to correspond to the standard output stream.
  • A streamis an abstraction that refers to a flow of data. The standard output stream normally flows to the screen display although it can be redirected to other output devices.
  • The operator << is called the insertion or put to operator. It directs the contents of the variable on its right to the object on its left.
  • In our program it directs the string constant <<"Welcome to this course\n" to cout, which sends it to the display.
  • (If you know C), you’ll recognize <<as the left-shift bit-wise operator and wonder how it can also be used to direct output.
  • In C++, operators can be overloaded. That is, they can perform different activities, depending on the context.




Comments