Terminal commands for installing g++ 4.8?

Solution 1:

For 13.10:

Just use sudo apt-get install g++-4.8.

For 13.04 and earlier:

Use the ubuntu-toolchain ppa:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.8