Usually, when installing software under centos, use yum.
The key is, use yum to know what the name of the installation package is.
If you type yum install g++ directly, it will tell you that there is no such package.
So you should use gcc-c++, which is the name of this package.
So it should be executed:yum install gcc-c++
Install g++ under Ubuntu
sudo apt install g++
su: Authentication failure problem
carea@LAPTOP-AQD5VEMM:~$ su
Password:
su: Authentication failure
carea@LAPTOP-AQD5VEMM:~$ su passwd root
su: user passwd does not exist
carea@LAPTOP-AQD5VEMM:~$ sudo passwd root
[sudo] password for carea:
New password:
Retype new password:
passwd: password updated successfully
carea@LAPTOP-AQD5VEMM:~$ su
Password:
root@LAPTOP-AQD5VEMM:/home/carea#
ubuntu Failed to fetch 404 Error resolution
do-release-upgrade
apt-get update
apt-get install g++