1

If I have a program header file named program.h and a template named program.template, I learned that you need to #include "program.template" at the bottom of the program.h file before #endif. This seems inconsistent with previous methods of having #include on the top of the file. Why is this?

My other question is, do you need #include "program.h" in the program.template file? Why or why not? If so, on the top or on the bottom of the file?

Thanks!

Overtaker
  • 71
  • 5

1 Answers1

1

#include is a C/C++ preprocessor directive. It tells the compiler (pre processor component) to dump the contents of file X (e.g. a header file) into the source code of the current file at the #include location.

The #include directive can be used in many ways which require placing it at the start, end or the middle of another header/C/CPP file.

Without seeing your code, it's hard to tell what or why it was done.

egur
  • 7,830
  • 2
  • 27
  • 47