Header files

If one wanted to, could he, say, make his own header file to make programming easier?
Yes. It's very, very, very common and completely expected.
And not just a header file. You'll eventually want to create a whole library of commonly used classes and functions for personal use.
closed account (zb0S216C)
Prototype functions are a requirement in C++. Prototypes are commonly (and should) be placed within header files. The use of header files is encouraged as it brings clarity to the table (so to speak).

Adding to what Athar said, libraries require a header which is used as an interface to the functions within. Without that header (s), you won't be able to call the functions within the library.

Wazzak
Okay. I was asking because I was thinking about when I'm better at programming I should probably do that.
I think the main point of a header is to let you share variables between two main files. Now just make a myHeader.h and place it in the same directory as your .cpp file. You can now put all of your global variables and classes here.

1
2
3
4
5
6
7
8
#include "myHeader.h"

int main()
{
  do_something();

}
javascript:editbox1.editSend()
I think the main point of a header is to let you share variables between two main files. Now just make a myHeader.h and place it in the same directory as your .cpp file. You can now put all of your global variables and classes here.


No!!!

Global variables are evil. The fewer the better.
Topic archived. No new replies allowed.