How do you make your own header files? Help please!


I'm not talking about just a text file with code, I mean
a header file containing functions C++ or any other header library has.
:) Hope you can help. Thanks.
-legit





A header file is just a text file with code. If you want to put function in it, just put functions in it.

http://www.cplusplus.com/forum/articles/10627/
I think the question may be not really about the header file, rather it is about the library file which contains the compiled code of the functions.
I see. In which case, that's also easily answered. Write the functions, compile them (whilst telling your compiler that you want a library rather than an executable) and bingo - you've got a library. Link to it as usual.
I don't think you get where I'm coming from. I want to create my own functions.
And he told you how to do so. Create a header file, write your functions and then include the header wherever you need to call said functions.
1
2
3
4
5
6
7
8
9
10
11
12
//Header.h
int Func(int param)
{
return param;
}

//main.cpp
#include "Header.h"
int main()
{
return Func(0);
}


EDIT: Although a header should only contain function declarations. You should stick the definitions in a separate cpp file.
Last edited on
I want to create my own functions.


Did you read this?
http://www.cplusplus.com/doc/tutorial/functions/
You're going to need brick and mortar.

And love. Lots of love.

Love and cookies.
Topic archived. No new replies allowed.