From the GCC manpage:
For any given input file, the file name suffix determines what kind of
compilation is done:
file.c
C source code which must be preprocessed.
.
.
.
file.h
C, C++, Objective-C or Objective-C++ header file to be turned into
a precompiled header.
file.cc
file.cp
file.cxx
file.cpp
file.CPP
file.c++
file.C
C++ source code which must be preprocessed. Note that in .cxx, the
last two letters must both be literally x. Likewise, .C refers to
a literal capital C.
What it doesn't do is automatically link to the C++ standard libraries. It's easiest just to use g++
at that point.