Alex Rivera | Logout

Does std::cout have a return value?

Asked 2012-06-11T20:35:05.140
11

I am curious if std::cout has a return value, because when I do this:

cout << cout << "";

some hexa code is printed. What's the meaning of this printed value?

Edit
Report

1 Answer

16

cout does not have a return value. cout is an object of type ostream. operator << has a return value, it returns a reference to cout.

See http://www.cplusplus.com/reference/iostream/ostream/operator%3C%3C/ for reference.

The only signature that matches is:

ostream& operator<< (ostream& ( *pf )(ostream&));

so it returns the pointer to the operator<< member.

the one in James' answer. :)

answered 2012-06-11T20:36:04.473

Your Answer