[prog] [C/C++] what to put in header files.

Terri Oda terri at zone12.com
Mon Sep 23 17:20:08 EST 2002


> May I add something to this advice?  If Foo.h uses anything from class Bar,
> then Foo.h should include Bar.h.  Not only does this make it easier users of
> class Foo since they only need to include Foo.h but it may be required for
> C++ template instantiation on some systems.  Of course, I always guard
> multiple inclusion of dependent header files within files.

Oh, and no matter what you're ever told, including a .cpp file isn't
considered very good practice.  :)

I've seen a university prof tell his students to do this "because it makes
things easier" and, well, it's a long story of assumptions and dependencies
in a few programming environments...  I'll just say that it most definitely
didn't make the students' lives any easier.

 Terri



More information about the Programming mailing list