suppose I have a header foo.h like this:
#ifndef FOO_H
#define FOO_H
#include
#include \"non_standard_class.h\"
std::string foo(
The practice I follow:
#include if there is std::string in foo.h)Another formulation of this practice: in foo.*, include only those headers the source code needs. If a header is needed by only foo.cpp (but not by foo.h), then include it from foo.cpp, otherwise include it from foo.h.
So, in your case, I wouldn't #include in foo.cpp, because it's already included by foo.h.
Let's assume that string does an #include , and foo.h contains std::vector. In this case, I'd #include in foo.h, because its source code needs it – and it doesn't matter that string already includes it.