Code:
// this is module.h
#ifndef MODULE_H_INCLUDED
#define MODULE_H_INCLUDED
void myfunc ( void );
#endif
Code:
// this is module.cpp
#include "module.h"
void myfunc ( void ) {
}
You repeat the above as many times as necessary for however many modules you want to create.
When you want to use it (anywhere, not just in main), do
Code:
// this is main.cpp
#include "module.h"
int main ( ) {
myfunc();
}
Such an example would be compiled with
gcc module.cpp main.cpp
Or add both .cpp files to the project, if you're using an IDE.
This is pretty much what the FAQ says.