user3681722
user3681722

Reputation: 35

C++ Header files and their corresponding source files

I am a beginner who is currently learning C++. I just had a quick question. If I place an include statement such as, #include <vector> in a header file do I still need to declare the same statement in the source file that implements the header file? My first thought is no because the header file has it included shouldn't the source file, that includes the header, have access to all the include calls that the header has. Sorry if the question is kind of confusing and possibly wrong terminology. Thank you.

Upvotes: 2

Views: 130

Answers (1)

Quentin
Quentin

Reputation: 63114

Technically speaking you don't need to include it again, but as far as coding style is concerned it is better to explicitly list a source file's dependencies.

Upvotes: 0

Related Questions