Before installing, uninstall the old version of gcc and g++
sudo apt-get remove gccgcc-xx #There may be multiple versions, they must be deleted
sudo apt-get remove g++
sudo apt-get install gcc
To install the g++ compiler, you can run the command
sudo apt-get installbuild-essential
After the execution, the installation of gcc, g++, and make is completed.
build-essential is a whole set of tools, gcc, libc, etc.
You can check whether g++ is successfully installed by "g++ -v".
#Install debug tools
sudo apt-get install gdb