How to set gcc 4.8 as default gcc compiler
Assuming you're using bash (it's the default), then you can add /usr/local/bin as your top priority in PATH like this:

echo "PATH=\"/usr/local/bin:$PATH\"" &gt;&gt; ~/.bash_profile


This will ensure that /usr/local/bin is checked before all other areas of your path. Then just start a new terminal session to load the new variable. 

Another way to do this: 

  cd /usr/bin
  rm cc gcc c++ g++
  ln -s /usr/local/bin/gcc-4.8 cc
  ln -s /usr/local/bin/gcc-4.8 gcc
  ln -s /usr/local/bin/c++-4.8 c++
  ln -s /usr/local/bin/g++-4.8 g++