I started learning C++ and I read a book which writes that I must use the header file because the string type is not built directly into the comp
Do I have to include the
header when I want to use the string type if I included theheader?
Yes, you have to. You cannot rely on relevant headers (e.g. ) being #included indirectly through other headers (e.g. ), although this might be the case on some implementations.
And even when this may seem to work, it could lead to troubles if not all of the relevant overloads of some operators are imported, or if a class is forward-declared in a header you #include, but information on that class being derived from some other class is only contained in a header that does not get #included.
See, for instance, this Q&A on StackOverflow for an example of such situations.