The rule is: Every header file should be capable of being compiled on its own. If you have a file myheader.h, then a source file with a single line #include "myheader.h"
should compile.
If your header file doesn't compile without including another header file, then include that other header file. However, there are cases where the problem can be fixed just by using a forward declaration like "class otherclass;", if that is a case then it is very much preferable.
So DON'T include header files without a need, and avoid the need if you can.
Why not include other header files that are only used by the source file? Because your header file is supposed to be shared with other files. It is supposed to contain things you want to share. Why would you want to share internal details of your source files, like what headers it needs? You should share as little as possible.
string
is required in A.h (because, for example, A.h contains a class definition with astring
member),string
should be included. So maybe you just misunderstood something?