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

Dan Richter daniel.richter at wimba.com
Wed Sep 25 10:27:43 EST 2002


>He actually told the students to include
>their .cpp file in the .h file, I believe, and then compile the .h file.  Or
>something equally confusing in the same vein.

Sometimes at the beginning teachers tell students to write header files 
like this:

#ifndef FOO_H
#define FOO_H

/* Interface stuff here. */

#include "foo.c"
#endif

This allows them to write all of their code as they normally would (placing 
interface definitions in the .h file while placing the implementation in 
the .c file), except for the one #include line, keep compilation simple. 
Presumably they teach them later how to compile "properly". I don't think 
it's very good to do, but many teachers do it.




More information about the Programming mailing list