Then I input g++ 1.cpp in my mac terminal, then nothing happens. However if I changed the code above a little (for example, get rid of a ;), then it complains.
Does anyone know how to let it show "Hello, world!"?
Odds are, if nothing was displayed after running the command, it just worked. Look for a file in that directory called 'a.out,' this is your compiled output file; run it by typing './a.out'
To name the output file, you would type g++ sourcefile.cpp -o outputfile