I have some code that uses an std::string in a file named executor.cpp. In the corresponding header file, executor.h I include #include <string>
. However, running cpplint on executor.cpp gives me the message that says :-
dec-session/executor.cpp:15: Add #include <string> for string [build/include_what_you_use] [4]
What am I doing wrong? Should I be including it in the executor.h?
Edited to account for the comment below. It's a false positive that you can ignore.
Generally, you should be including in executor.cpp and just forward declaring classes (
class Thing;
) in the executor.h.Hypothetically though, if you were to produce another version of the
Thing
class, then anything that includes executor.h would currently have to be recompiled. By moving the include into the cpp, you'd only have to recompile executor.cpp and re-link.