How std::cout works [duplicate]
Question:
I accidentally found:
cout << cout;
The output is some address. What does this address mean, and why is it shown?
I am looking this question.
Because ostream
overload operator
void*()
, and that's the closes match for the call to operator
<<
, the result of the cast (void*)cout
is
printed. Which in your case is that address. Remember that cout
is
an object.
Basically the call translates to:
cout.operator<<((void*)cout);
想要看到更多学习笔记、考试复习资料、面试准备资料?
想要看到IBM工作时期的技术积累和国外初创公司的经验总结?
敬请关注:
[CSDN](https://blog.csdn.net/u013152895)
[简书](https://www.jianshu.com/u/594a3de3852d)
[博客园](https://www.cnblogs.com/vigorz/)
[51Testing](http://www.51testing.com/?15263728)