I started learning C++ and I read a book which writes that I must use the <string>
header file because the string type is not built directly into the compiler.
If I use the <iostream>
I can use the string type.
Do I have to include the <string>
header when I want to use the string type if I included the <iostream>
header? Why? Is there some difference?
Yes, you have to include what you use. It's not mandated that standard headers include one another (with a few exceptions IIRC). It might work now, but might fail on a different compiler.
In your case, apparently <iostream>
includes <string>
, directly or indirectly, but don't rely on it.