$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt-get update
$ sudo apt-get install gcc-7
$ sudo apt-get install g+±7
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100
$ sudo update-alternatives --config gcc
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g+±7 100
$ sudo update-alternatives --config g++
$ gcc --version
$ g++ --version