Sending std::cout to std::cout

S

saurabh29789

I have a statement I'd like you to consider :

std::cout<<(std::cout<<"Hi");

that prints a Hii followed by some address.

The (std::cout<<"Hi") would be returning an object of type ostream,
but what is this address that is printed ?? How??
 
T

Tim Slattery

saurabh29789 said:
I have a statement I'd like you to consider :

std::cout<<(std::cout<<"Hi");

that prints a Hii followed by some address.

The (std::cout<<"Hi") would be returning an object of type ostream,
but what is this address that is printed ?? How??

It's printing the address of the std::cout object.
 
R

Rolf Magnus

Tim said:
It's printing the address of the std::cout object.

No. Well, maybe or maybe not. It's printing some address that is not NULL,
because std::eek:stream has a conversion operator to void* that returns a null
pointer if the stream encountered an error or some non-null poiner if it
didn't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top