I mean when you don't use the -c flag (which is when it will link and produce an executable file ).
In one step:
g++ file.cpp -o file.exe
In two steps:
g++ -c file.cpp -o file.o
g++ file.o -o file.exe
The order is only important with -o and the filename that comes after. All the other arguments that has been mentioned in this thread can be in any order.
Note that if you have multiple .cpp files you can either compile all files in one go:
Compiling each file separately has the advantage that you don't have to recompile all files when you only have made changes to some of them. This is very important for larger programs which can take minutes, sometimes hours, to compile from scratch. It's normally too difficult and error-prone to do this manually but it's essentially what IDEs and many Makefiles do.
Note that you can often use "wildcards" to simplify these commands (assuming you want to list all files with the same file extension in the same directory):