Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"cout << cout" - what does the output stand for?

Tags:

c++

std

After a long day of coding i accidentaly wrote

cout << "some text" << cout;

instead of

cout << "some text" << endl;

Now it printed out a memory address. What does it point to ?

like image 559
user2664856 Avatar asked Mar 05 '15 07:03

user2664856


People also ask

What does cout stand for?

The "c" in cout refers to "character" and "out" means "output". Hence cout means "character output".

What is the output of cout?

Standard output stream (cout): Usually the standard output device is the display screen. The C++ cout statement is the instance of the ostream class. It is used to produce output on the standard output device which is usually the display screen.

What is the use of cout << in C++?

It is used to display the output to the standard output device i.e. monitor. It is associated with the standard C output stream stdout. The data needed to be displayed on the screen is inserted in the standard output stream (cout) using the insertion operator(<<).

Is cout input or output?

There are two variables (among others) defined in <iostream>. cout is used for output, cin for input.


1 Answers

std::cout is an instance of std::ostream, and, before C++11, that had a conversion operator to void*. It seems your code is triggering that conversion, giving you the address of the std::cout object.

like image 82
juanchopanza Avatar answered Nov 02 '22 15:11

juanchopanza