I'm using Ubuntu 15.10, so the default g++ version is 5.2.1. Since I need to change it to the 4.7 often, I'm using update-alternatives; I've noticed, however, that the default compiler is not restored on closing the terminal; this may be an issue since there is the possibility to mix codes compiled with different compilers. Is there a way to force the shell to restore the default settings on exiting? Thank you in advice.
Edit: I wish to thank the_Seppi for his precious help