I\'m fairly new to C++, but my understanding is that a #include statement will essentially just dump the contents of the #included file into the location of that statement. This
using
statement in headers (unless inside function scopes)... Adding using
in the header will pollute the namespaces of all the sources including the header.You don't need to care if some includes are redundant. Header guards and precompiler optimizations are there to handle that for you.
You should be able to manipulate each file in isolation.
For example, let's say you use the std::string
in the header and in the source, but, as an "optimization", you only included the string in the header... If you discover later you don't need anymore the string in the header, and want to remove it (code cleaning, and all...), you will have to modify the source to include the string. Now, let's imagine you have TEN sources including the header...
Now, of course, you can have exceptions to this rule (for example, precompiled headers, or even headers woe sole aim is to do multiple includes as a courtesy), but by default, you should have self-sufficient header and source files (i.e. files that include anything they use, no more no less).