Pertaining to .h files.

As I'm sure many have before me, I hope I am not asking too simple a question or too common of a question.

I am trying to create a .h file such that my main program can call a function which is included in the .h file as though the function were included in the main file.

The .h file is included via #include.

If anyone could direct me where to look to learn how to do this, it would be much appreciated.

Thank you,
Tristan.
1
2
3
// myfunction.h

void myfunction();

1
2
3
4
5
6
7
8
// myfunction.cpp

#include "myfunction.h"

void myfunction()
{
    // do whatever here
}

1
2
3
4
5
6
7
8
9
// main.cpp

#include "myfunction.h"

int main()
{
    myfunction();  // call the function in another cpp file
    return 0;
}
Thank you, Disch. Looks like I was trying to over complicate it!

Again, much appreciated.
Topic archived. No new replies allowed.