Yes, the two versions will happily coexist. You can invoke each individually by specifically invoking it though only one version will have CC
aliased to it.
Install each separately with:
sudo apt-get install gcc-4.7
sudo apt-get install gcc-4.8
When you are ready to compile with a specific version invoke it explicitely:
gcc-4.7 source.c -o executable
or
gcc-4.8 source.c -o executable