How to compile a c++ program in Linux?
Use g++
g++ -o hi hi.cpp
g++ is for C++, gcc is for C although with the -libstdc++ you can compile c++ most people don't do this.
You have to use g++ (as mentioned in other answers). On top of that you can think of providing some good options available at command line (which helps you avoid making ill formed code):
g++ -O4 -Wall hi.cpp -o hi.out
^^^^^ ^^^^^^
optimize related to coding mistakes
For more detail you can refer to man g++ | less
.
As the other answers say, use g++ instead of gcc.
Or use make: make hi