If a particular header already included in stdafx.h - do I need to (have to/should to) to explicitly include it in a .cpp file?

StackOverflow https://stackoverflow.com/questions/4251511

Question

If a particular header is already included in stdafx.h - do I need to (have to/should to) to explicitly include it in a .cpp file (which already includes the stdafx.h) ?

Was it helpful?

Solution

When stdafx is created for you it is typically a precompiled header. As a precomiled header it will be necessary to add it to any .cpp that is marked to use precompiled headers (normaly any cpp added to the project except for stdafx.cpp)

You don't need to include headers already included in stdafx.h, including it again may cause extra effort for the compiler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top