step one: open the terminal
step two: mkdir ~/programs
Type mkdir ~/programs into the the terminal to create a folder or 'directory' called 'programs', in your 'home directory'. mkdir stands for 'make directory'.
step three: cd ~/programs
Type cd ~/programs to change the directory your terminal is referring to from your 'home folder' to your new 'programs' directory where you will write the code for your program.
step four: g++ --version
Type g++ -- version to make sure you have the GNU C++ compiler
The message above is the response I get from my terminal after I enter the command g++ --version. I believe this response indicates that I do have the GNU C++ compiler.g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3Copyright (C) 2009 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
step five: Write the code
Now you have to open a text editor and write the code for your app. For my first app I wrote the code for "Hello World", simple text output. You have to save the text file with the .cpp extension or the G++ compiler may not recognize the source code file. Save the source code in the 'programs' directory you created.
step six: g++ -o hello_world hello_world.cpp
This command will compile the hello_world.cpp file to an executable called hello_world in the same directory.
step seven: Run your program with ./hello_world
./ means 'in current directory'. If you copy pasted or wrote the code yourself with no errors then the program should say "hello world" in the terminal. In Ubuntu you don't have to worry about the terminal shutting down as you have to in Windows.