“cout << cout” - what does the output stand for?

做~自己de王妃 提交于 2019-12-19 16:13:32

问题


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 ?


回答1:


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.



来源:https://stackoverflow.com/questions/28872624/cout-cout-what-does-the-output-stand-for

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!