This tells the compiler (g++) where to find the source code and how to name the resulting program.
In case you omit the name of the output program the result will most likely be an executable file called "a.out".
The flags at the end of the command tell the compiler which version of C++ to use (C++ 2011) and to trigger all warnings your code might produce and elevate them to errors.
It is generally a good practice to use these last two flags.
If your code does compile without these two options but does not compile with them, chances are high that there is still a programming error in your program.