Lorem ipsum dolor sit amet, consectetur adipiscing elit. Test link
Posts

5.3 cerr (error stream)

1 min read
Image result for cerr (error stream) C++


The predefined object cerr is an instance of iostream class. The cerr object is said to be attached to the standard error device, which is also a display screen but the object cerr is un-buffered and each stream insertion to cerr causes its output to appear immediately.

The cerr is also used in conjunction with the stream insertion operator as shown in the following example.
int main( )
{
char str[] = "Unable to read....";
cerr << "Error message : " << str << endl;
}

When the above code is compiled and executed, it produces the following result:
Error message : Unable to read....

                        5.4 clog (log stream)           NEXT >>

You may like these posts

  • Object Oriented Programming has a special feature called data abstraction. Data abstraction allows ignoring the details of how a data type is represented. While defining a clas…
  •   Constructor A constructor is a special kind of class member function that is executed when an object of that class is instantiated. Constructors are typically used to init…
  • Polymorphism "Poly" means "many" and "morph" means "form". Polymorphism is the ability of an object (or reference) to assume (be replaced by) or become many different forms of…
  • Inheritance is one of the key feature of object-oriented programming including C++ which allows user to create a new class(derived class) from a existing class(base class). The…
  • You can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of argu…
  • A friend function of a class is defined outside that class' scope but it has the right to access all private and protected members of the class. Even though the prototypes for f…

Post a Comment