I am a beginner with C++. When I write the code sometimes I write #include and the code works, other times I don\'t write #include
As Branko said:
It is possible that other headers that you do include have #include in them.
Let's take a look at iostream includes:
#include
#include
#include
if you check istream you can see some include
so like this, we have:
iostream => istream => ios => iosfwd
and in iosfwd we have string library! but it's not standard, it's for forward declaration. in iosfwd we have:
#include
// For string forward declarations.
and in stringfwd.h:
@file bits/stringfwd.h This is an internal header file, included by other library headers. Do not attempt to use it directly. @headername{string}
so, You can use string without #include .