I want to see source code of STL std::cout
function. I looked at iostream, but I've seen only "extern cout". So, I guess that it's defined somewhere in the library.
I downloaded source code from official site
I extracted it and did:
sh@sh-R528-R728:~/desktop/stl$ grep -F * | grep "cout"
but I got nothing.
What am I doing wrong? Where is the source code?
cout
is not part of the STL, so you won't find the source for cout
in the STL source.
You probably want to look for the source for your C++ standard library, which was based on the STL, but also contains iostreams. Where that is depends on what platform you're using.
If you happen to be using GCC, then libstdc++
is your C++ library. Its sources can be found on gcc.gnu.org. cout
is defined on line 58 of src/c++98/globals_io.cc
.
std::cout
is not a function, it is a instance of std::ostream
(interface description) that is tied to standard output.
If you are using gcc/libstdc++, have a blast browsing its source code online