If apt is working and that is what you are going to use on Kali Linux (which I do not recommend to Linux beginners, as Kali Linux is a very advanced tool for security experts to try out!
), then just execute the following command:
sudo apt-get install g++
However, since that command (the one you are using) is also possible (because Kali Linux is a Debian distro; like Ubuntu!), you should execute that as super-user! Currently you are not executing that as a superuser, whereas in Linux environment all of the install or uninstall and similar commands require to have superuser authentication. Either prepend
(command to execute the commands with super-user privileges
), or use the root terminal (which would, at the beginning, ask for your password).