Change C++ version [duplicate]

The CXX variable doesn't affect how the shell resolves program name g++: that just follows the usual conventions of your executable search path $PATH, and is finally determined by a symbolic link e.g. on my 14.04 system

$ which g++
/usr/bin/g++

while

$ ls -l $(which g++)
lrwxrwxrwx 1 root root 7 Apr  7  2014 /usr/bin/g++ -> g++-4.8

If you want to change that, you will need to re-make the symbolic link either manually e.g.

sudo ln -sf g++-4.4 /usr/bin/g++

or using the update-alternatives mechanism.

However, many build processes will respect the setting of CXX (and the equivalent CC for the C compiler, FC for the Fortran compiler and so on) so that there is often no need to change the default compiler(s) via symlinks: if there is a particular software build that you are having difficulty with then I suggest you post a question about that specifically.