Making your own header files

closed account (42hU7k9E)
I need a good explanation about making header files, and should be explained werry nice and understandable.

Thank you, kajzec
Can you be a little more specific?
closed account (42hU7k9E)
I was thinking of a header, that had a function for addition, multyplying etc. Is that even possible?
Headers usually contain:
* An inclusion guard to prevent errors.
* Inclusion of other headers that contain declarations that the ones in it require (for example, a header that declares a function that returns an std::string would #include <string>).
* Declarations necessary by all files that include it.

Following my previous example, a header could look like this:
1
2
3
4
5
6
7
8
9
10
11
//Necessary inclusions:
#include <string>

//Inclusion guard. It will prevent the same header from being included twice in
//the same file:
#ifndef EXAMPLE_H
#define EXAMPLE_H

//Definitions:
std::string some_function();
#endif 
Topic archived. No new replies allowed.