I have a file named main.cpp which includes iostream.
I compiled main.cpp and it worked without errors, so my question is: I compiled main.cpp and I did not link iostream with main.cpp, so how could this be possible? Or did the compiler linked the iostream automatically?
The functions in
iostreamare part of the C++ standard library, which you usually don’t need to link explicitly.If you use a compiler that’s not strictly a C++ compiler, you sometimes need to add something like
-lstdc++(at least, I do if I usegccrather thang++).