It seems that you're trying to "run" this as a shell script.
That won't work, you have to invoke g++ to make a binary out of your source code, which you can then execute.
i compiled with the command g++ test2.cpp
no errors
i also can see the a.out file
tutorial tell me after i change permissions (chmod u+x)
i should just be able to type test2.cpp or a.out and it will execute but that returns command not found error
so I tried a ./test.cpp
and the errors were returned