Hi guys
Ive been searching on the web for a while know trying to find out exactly what code to include in header files whenever I search I just find lots of different people saying lots of different things. I want to know if I should include class and function definitions in my header files or class and function declarations? Also I don't see the advantage of just including declarations in the header files so if someone could try and explain this to me I would be most grateful
if i understood you correctly
Firstly,you create a new file:
Examlpe "Vetor.h"
after writing a code
when you use it
you need declare:#include"Vector.h"
good luck
i hope it usefully.
Hey guys I'm back after reading the article that firix recommended, which was helpful but it still left me confused as to what you put in header files is it class/function declarations or definintions
do nothing if: A makes no references at all to B
- do nothing if: The only reference to B is in a friend declaration
- forward declare B if: A contains a B pointer or reference: B* myb;
- forward declare B if: one or more functions has a B object/pointer/reference
as a parementer, or as a return type: B MyFunction(B myb);
- #include "b.h" if: B is a parent class of A
- #include "b.h" if: A contains a B object: B myb;
- Class bodies go in header files
- Function prototypes go in header files
- Inline function bodies go in header files
- Template function bodies go in header files
- non-inline, non-template function bodies go in .cpp files.
(Generally. There are, of course, exceptions to the above rules)