G++ is a compiler for C++ programs. Like GCC (its sister project), it can also compile C programs, but any programs with G++ will be compiled as C++ files.
To compile a C++ file, we can execute:
g++ -std=c++11 -g –Wall hello.cpp –o hello
./hello
Flags
-Wall
to enable warnings.-g
to compile in debug mode.-std=c++xx
to compile according to a certain language standard (for example, replacexx
with11
).