How do I avoid re-including <iostream> in multiple files?

c++

Solution

No, there is nothing wrong with it. Every file that needs to directly use functionality from `<iostream>`, should include it directly. Header guards will take care of multiple inclusions.

There is a potential problem when you have circular dependencies. For example, see this question: Resolve header include circular dependencies

However, since `<iostream>` is unlikely to be including or depending on any of your files, circular dependencies are not a problem in this case.

Problem

If I have multiple files that `#include` each other, and all `#include <iostream>`, is this considered bad, and if so, how would I avoid it?

Original source

Related problems