(elaborating what was already hinted in comments)
C++ is a (usually) compiled language. (Although there exist interpreters as well, XCode with clang or gcc do not belong to them.)
The source code (as exposed by OP) is compiled into machine code executable by the CPU. (Usually, it is the CPU the compiler runs on but it might be for another as well → cross-compiling.) Machine code is a binary code (hardly readable by the average user) which is the only code which can be directly "interpreted" by the CPU.
The produced executable has to be started using specific functions of the OS (e.g. fork()
and exec()
). A shell (e.g. bash
) is able to do this but it can be programmed into other programs as well.
IDEs (like XCode or VisualStudio) provide commands (buttons) for compiling and starting. A "Play" button checks whether the source code has been changed since last compiling. If so, it is compiled again and the outcome stored as executable file. (Otherwise, the compile might be skipped.) Afterwards (assuming there wasn't any compile error) the IDE fork()
s a process to exec()
s the executable file (i.e. the compiled program).
Once, a program terminates it returns a number which can be received in the parent process (which started the program). If the parent process was e.g. bash
then the return code is stored in a variable which can be retrieved afterwards.
echo $?
prints the returned value of last terminated child process.
An IDE may report the returned value in some kind of log window. In VisualStudio, it's the Output window. As OP described in the question, it seems to be similar in XCode.