There's a version of the free and open source GNU C++ compiler (g++) for every major desktop platform. For Unix/Linux, it's probably already installed. Some Linux distros only incude the C compiler, so you may have to download additional packages to get g++. It should be listed in your graphical software installer.
For OSX, download the Xcode package from Apple. See:
http://developer.apple.com
Windows has two major GNU ports: MinGW generates native windows executables, and Cygwin generates Unix-like executables that run with assistance from an adapter DLL. Prefer MinGW for writing new code, or Cygwin for easy porting of Unix-specific code to a Windows environment. I have both installed under WIn7.
http://www.mingw.org
http://www.cygwin.com
An easy way to get MinGW, plus a decent IDE that's also free and open-source, is to install Code:Blocks bundled with the MinGW port of the GNU tools. (Code:Blocks is also available for Unix, Linux, MacOS(X) and others.)
http://www.codeblocks.org
Also for Windows, you should have Visual C++ around, even if it's not your main compiler. The version in the free Visual Studio Express is the full compiler, minus a few MS-specific libraries like the legacy MFC framework. You probably won't need that.
http://www.visualstudio.com/products/visual-studio-express-vs
(Get the "Windows Desktop" version.)