man gcc says:
C++ source files conventionally use one of the suffixes .C, .cc, .cpp, .CPP, .c++, .cp,
or .cxx; C++ header files often use .hh, .hpp, .H, or (for shared template code) .tcc;
and preprocessed C++ files use the suffix .ii. GCC recognizes files with these names and
compiles them as C++ programs even if you call the compiler the same way as for
compiling C programs (usually with the name gcc).