cpp output operator

C++ output operator

cplusplus output operator picture

causes the string in quotation marks to be display on the screen. this statement introduces two new c++ features,cout and << the identifier cout is a predefined object that represent the standard output stream in c++ Here the standard output stream represent the screen.
it is also possible to redirect the output to other output devices. and the operator << is called the insertion or put to operator. it inserts(or sends) the contents of the variable on its right to the object on its left

The object cout has a simple interface. if string represent a string variable, then the following statement will display its contents:

cou << string;

you can be call that the operator << is bitwise left-shift operator and it can still be used for this purpose. this is an example of how one operator can be used for different works. so we can also say this concept is know as opearator overloading. in the c language we use printf() function for displaying string on screen.

1. In C++ input output operation is using the stream concept. Stream is the flow of data or sequence of bytes. It makes the performance fast.
2. If the bytes flows from main memory to device like display screen, network connection, printer, etc, this is known as output operation.
3. If the bytes flows from device like display screen, network connection, printer etc to the main memory, this is known as input operation.

I/O Library Header Files

Let us see the common header files used in C++ programming are:

Header File Function and Description
< iostream > It is used to define the cout, cin and cerr objects, which correspond to standard output stream, standard input stream and standard error stream, respectively
< iomanip > It is used to declare services useful for performing formatted I/O, such as setprecision and setw.
< fstream > It is used to declare services for user-controlled file processing.

Standard output stream (cout)

The cout is a predefined object of class ostream . This is connected with the standard output device, which is usually a display screen. The cout operator is used in conjunction with the (<<) stream insertion operator to show the output on a console.

Let’s see the simple example of standard output stream (cout):

#include<iostream>
using namespace std;
int main( )
{
char arr[] = "Welcome to programmingknow tutorial";
cout << "Value of char arr is: " << arr << endl;
}

Value of char arr is: Welcome to programmingknow tutorial

  • C++ Dynamic Initialization of Objects
  • C++ Copy Constructor
  • C++ Dynamic Constructor
  • C++ Destructors
  • C++ Exercise
  • C++ Operator Overloading
  • C++ Overloading Unary Operators
  • Const pointer in C
  • Void pointer in c
  • C++ Overloading Binary Operators
  • C++ Overloading Binary Operators Using Friends
  • C++ Manipulation String Using Operators
  • C++ Rules for overloading operators
  • C++ Exercise
  • C++ Basic To class Type
  • C++ Class TO Basic Type
  • C++ One class To another class type
  • C++ Exercise
  • C++ Inheritance introduction
  • C++ Single Inheritance
  • C++ Multiple Inheritance
  • C++ Ambiguity Resolution in inheritance
  • C++ Hierarchical Inheritance
  • C++ Hybrid Inheritance
  • C++ Virtual Base Classes
  • C++ Exercise
  • C++ abstract class
  • C++ nesting of classes
  • C++ Exercise
  • C++ polymorphism
  • C++ Exercise
  • C++ pointers
  • C++ Pointers TO object
  • C++ this pointer
  • C++ Pointer to Derived class
  • C++ Virtual functions
  • C++ Exercise
  • C++ streams
  • C++ unformatted I/O operations
  • C++ Put() and get()
  • C++ getline() and write()
  • C++ Formatted console I/O
  • C++ Manipulators
  • C++ Exercise
  • C++ file handling
  • C++ file stream classes
  • C++ Open and closing file
  • C++ open using constructor
  • C++ open using open()
  • C++ Detecting End of file
  • C++ File modes
  • C++ File pointers and Manipulators
  • C++ Sequential I/O
  • C++ Reading and Writing
  • C++ Updating a File
  • C++ Error handling In File
  • C++ Command Line Arguments
  • C++ Exercise
  • C++ Template introduction
  • C++ Class Templates with multiple Parameters
  • C++ Function templates
  • C++ Function templates with multiple parameters
  • C++ member function Template
  • C++ Exercise
  • C++ Exception handling
  • C++ Basics of Exception Handling
  • C++ Exception Handling Mechanism
  • C++ Throwing Mechanism
  • C++ Catch Mechanism
  • C++ Catch all Exceptions
  • C++ Re-Throwing An Exception
  • C++ Specifying Exceptions
  • C++ Exercise