What happens when I run the former command? I'm guessing a default version standard of the C++ compiler gets called, but I don't know which?
When you run g++
without specifying a C++ language standard to use, it will use whichever one was decided to be the default when none is specified.
The default C++ language standard used by GCC depends on the version of GCC you're using. See GCC's C++ language support status documentation, which at the time of this writing states:
C++17 features are available since GCC 5. This mode is the default in GCC 11; it can be explicitly selected with the -std=c++17 command-line flag, or -std=gnu++17 to enable GNU extensions as well.
GCC has full support for the of the 2014 C++ standard. This mode is the default in GCC 6.1 up until GCC 10 (including); it can be explicitly selected with the -std=c++14 command-line flag, or -std=gnu++14 to enable GNU extensions as well.
GCC has full support for the 1998 C++ standard as modified by the 2003 technical corrigendum and some later defect reports, excluding the export feature which was later removed from the language. This mode is the default in GCC versions prior to 6.1; it can be explicitly selected with the -std=c++98 command-line flag, or -std=gnu++98 to enable GNU extensions as well.
If you're interested in language / standard library support for other compilers as well, you can see Clang's C++ support documentation or cppreference.com's compiler support page.
And as a programmer/developer, should I always use the latter command with the extra argument?
I don't know about whether you should, but the obvious is that you'll need to if you want/need to use a specific language standard, unless the one you want/need to use happens to be the default for the version of GCC you're using.
-std
changes the semantics of the compiler, rather than run an entirely different complier. Are you interested in the complier ("gcc" vs "clang" vs ...) or standard that the compiler attempts to conform to ("C++17" vs "C++11" vs ....)?