You should never put actual code in a header file. Header files are designed to make declarations available to a number of source files. Declarations tell the compiler how functions are supposed to work, and that there will be variables defined somewhere prior to the link process.

If you put actual definitions into a header file, and include it in more than one source file, multiple definition errors will be the result.

You need to understand how the build process works. First, the preprocessor runs. This will copy the header files and paste them directly into the source file. This happens before the compiler runs. The compiler works with this end result.

In your case, since you have not included a code file into multiple files, but only into main.cpp, you should not get errors. You should merely get warnings that you have done something useless.

What you want to do here is to make a project with more than one source file. Your utility file (what your are now calling header.cpp) should be part of the project, and compiled separately. It does not need to include header.h, since it defines those procedures.

Your main file, main.cpp, will also be compiled separately. It needs to include the header.h file so that it know if your are calling the utility procedures correctly.

After these two file are compiled, they are linked. This means that the linker must have access to the actual code generated by header.cpp, not just explanations of how to call the functions. The linker will reconcile the two object files generated by the compilation and put the actual address of the functions in header.cpp into the calls seen in main.cpp.

These ultimate addresses may be modified by the OS (or they may not), but even if they are they will be in agreement and will result in the desired operation.