Devc++ and header files
Hi i created my first header file but cant fathom out how to use it.I have saved it as .h file extension and its in the folder where all my source files are saved.Any tips?
heres the header file code,with some of the functions just in case the fault is in the code:
int playerdam(int &gobHealth)
int gobdam(int &playerHealth)
In the main .cpp file you need
Thanks was using
Also I had the header file in diffent folder to my main source code.
You live and you learn!
thanks for the help
It is perfectly valid to have the header in a different folder, but if it's part of your application, then it should use the double-quotes rather than <> to tell the reader "this is one of MY files".
Also, most header files usually only contain declarations for functions and put the definitions in a .cpp file.
Actually, using double quotes means that the path you give it is relative to the project's directory and using <> means it's relative the the compiler's include folder
Originally Posted by matsp
Actually, the rules go something like this:
Originally Posted by h_howee
- For "file.h": search in compiler-specific directories usually relating to the project. Typically this means ".". If the header file is not found, proceed as if it was <file.h>.
- For <file.h>: search in compiler-specific directories usually relating to system-wide header files and libraries. Usually this is the standard include directory; however, these paths can often be added to with a command-line parameter. For example, to compile SDL programs you often use -I /usr/include/SDL, which tells the compiler to look for <file.h> in /usr/include/SDL as well as the usual places.
Anyway, the details aren't really important. Just use "file.h" for header files that you create, and <file.h> for standard system header files like <iostream>. Additional libraries like the SDL can use "SDL.h" or <SDL/SDL.h>. The former is more portable but you have to pass extra parameters to the compiler.