#includes in header files

Started by
10 comments, last by Blew 20 years, 1 month ago
I strongly disagree with your teacher.

A header file should ''stand on its own'' when seen from an implementation file''s point of view. The user shouldn''t have to remember that he must include "foo.h" "bar.h" before all inclusions of "baz.h", and "quux.h" after that.

If a given header always require other headers to work, it is this header''s responsibility to include them, not the users of that header.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan (C programming language co-inventor)
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Advertisement
Finished with university eh? When you get into the real world, depending on the size of the corperation, you''ll be given programming standards for multiple-programmer efficiency purposes. And then one object per file and one definition per header is a pretty strong standard.

Your professor should have told you that.
william bubel

This topic is closed to new replies.

Advertisement