Include's

This is just a general "best practices" question. Let's say header file X has an include Y but header file X also has an include Z which is including Y. Is it bad practice to not include Y inside of X considering header Z already has that it?
Last edited on
First, it should not matter, because include guards and proper style etc should have the above scenario work fine.

Second, your scenario: X does not need Y, it already has it. The reason you may include Y would be, what if Z were modified to no longer need Y (say it only used one tiny bit of Y and that was removed in an edit or something). If you did not have Y in X, now you have to run down an aggravating problem of 'why did that break'. This would not be a huge ordeal for one file, but this sort of thing has a habit of exploding in huge projects. I won't try to guess what best practice for *that* would be; but there are multiple ways to handle it in the language.
Oh yes, of course, that makes sense thank you.
Topic archived. No new replies allowed.