How to install g++ or c++ without paying for xcode?
You can still download Xcode 3.x for free with a free developer account. Xcode 3 comes with the GCC 4.2, LLVM-GCC 1.5 and LLVM 1.5 so everything you need to compile C++, C and ObjC code.

(Remark: LLVM 1.5 can't compile C++ code, so you have to switch back to LLVM-GCC or GCC for this.)