Locked What is cout?

  • Friday, March 17, 2006 12:53 AM
     
     

    It may sound silly but what is cout?I am a newbie and I just ask out of curiosity because I see it a lot lately.Is it useful?

     

All Replies

  • Friday, March 17, 2006 1:01 AM
     
     Answered

    It writes output as a byte stream. It is one of the members of iostream.

    Take a look at http://msdn2.microsoft.com/en-us/library/bzbx67e8(VS.80).aspx & http://msdn2.microsoft.com/en-us/library/yeecc295(VS.80).aspx for more details

    Here is an example of how to use cout to print "Hello World"

    #include <iostream>
    using namespace std;

    int main()
    {
     cout<<"Hello World\n";
     return 0;
    }

    Hope this helps!

    Note: I really advise you to read some books about C++ since the forums won't help you learn the language.

    Thanks,
    Ayman Shoukry
    VC++ Team

     

  • Friday, March 17, 2006 6:47 AM
     
     
    You bet!Imagine that once in a while I always have a question,thus we do C++ in the university,plus the forums I visit so as to help myself get out of this mess.Thanx for the help BTW!
  • Monday, November 29, 2010 5:02 PM
     
     
    I decided to look this up, as I'm a vb programmer trying to learn c++ myself.  What I found is that cout is an object of the class ostream (from: http://www.cplusplus.com/reference/iostream/cout/), so it would inherit all of the members and member functions of the ostream class.  The members and member functions are what we call properties and methods in vb (members/properties hold data and member functions/methods are subprograms that operate on data).  I think cout is usually set to stdout, the standard output stream, which is usually set to the terminal.  I'm not yet totally sure on what a stream is... that's my next order of business!
  • Monday, November 29, 2010 6:10 PM