I'm learning C++, and I'm working on a project. In this project, I need to call functions inside functions to allow navigation on a square grid. I have my functions defined above my int main(), then a short user input that calls the first function to get it started. However, when compiling, it won't let me compile a function that calls a function that hasn't been defined yet. I was wondering how I could fix this, and if it was to put all my functions inside a header, and then include the header in the main file that calls the first function.
Then it depends on the compiler you're using, but if you're compiling from the command line it will look something like this (example with gcc, other compilers will obviously look a bit different, but with mostly the same process).
1 2 3
gcc -c MySource.cpp //compile MySource to MySource.o
gcc -c main.cpp //compile main to main.o
gcc MySource.o main.o -o test //link MySource.o and main.o to test
In and IDE, this will be done automatically just by adding the source file to the project and then hitting compile. Is that clear?