The general structure for C++ headers is
Start with a Macro Guard.
This can either be a
#pragma once
(Microsoft Visual Studio 7.1 or later only) or a
#define
This stops any classes, functions and external variables getting defined multiple times if the header is included from multiple locations.
If you use the
#define
the variable defined must be unique for the entire solution, a common naming style is
__HEADERFILENAME_H__
where HEADERFILENAME is the name of the .h file
Then you simply provide prototypes for the functions and definitions of classes, structs, enums, ...
MyHeader.h
#ifndef __MYHEADER_H__ //Must be unique
#define __MYHEADER_H__ //Must match the previous line
typedef struct {
int nSomeVar;
} SomeStruct;
int SomeFunction();
#endif
The idea is that the code for
int SomeFunction();
is in a different .cpp file than what you are trying to use it from