Functions in a Header File

Hello,

How would you write functions in a header file, and then call it to your main.cpp.
Can someone please give me an example.

-Code Assassin
closed account (zb0S216C)
Function interfaces should only be placed within header modules, except for templates. Headers with prototype functions should have an associated source module that contains the definitions of the function prototypes. A simple header module would look like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Header.h
#if !defined( MY_HEADER )
#define MY_HEADER

void my_function( );

#endif

// Source.cpp
#include "Header.h"

void my_function( )
{
    // ...
}

I'd just like to say that header modules with the .h extension is C style. C++ headers have no extension :)

Wazzak
Thanks, Framework.
.....

Weird, I inputted your template and It's not working.
Nvm, I solved my problem. :)
Topic archived. No new replies allowed.