Enter this into a text editor (if you don't know open beaver from the icon and use that) and save it as hello.cpp in your home directory (/home/dsl).
To compile it, open an xterminal (which should put you in the /home/dsl directory) and enter the command line:
g++ -o hello hello.cpp
This should produce and executable called hello, so type hello in the shell and hit return and it should print the hello message. gcc is the C compiler, g++ is the c++ compiler. You might want to run the g++ program from the same directory that your *.cpp files are in until you get used to paths and such.
original here.