To run C++ code, you need a compiler. A compiler is a tool that turns the .cpp source code you write into an executable program the computer can understand. You can get started with an online playground, but once you want to build real projects, knowing how to set things up locally becomes essential.
cpp
# Save your file as hello.cpp
# Compile with g++
g++ hello.cpp -o hello
# Run on macOS/Linux
./hello
# Run on Windows PowerShell
.\hello.exehello.cpp is the source file, and g++ is the compiler. -o hello names the output program hello. Compiling first and then running is the standard C++ workflow.
You should see
If compile succeeds, your program runs and prints the output from your code.Info
On Windows you can use MinGW-w64 or the Visual Studio Build Tools, on macOS the Xcode Command Line Tools, and on Linux the g++ package.