to compile a c++ program in windows, as far as i know, we must have some IDE (Integrated Development Environment) and compile from there. 2 free IDEs are:

  1. Dev-C++ from Bloodshed Software (
  2. Eclipse IDE for C/C++ Developers (
in Linux and Mac, since they are both running UNIX, thus they are the same.
in the terminal, use the command “g++”:
        g++ file.cpp -o output.file
For execute the output file, type:

there is other way on Mac, is the Xcode. you can either download it (pay) or install it from the application CD comes with your Mac.