Writing Library Files for the Arduino
This describes the basics of writing a C++ class
http://www.cplusplus.com/doc/tutorial/classes/
To compile on a mac:
% g++ -Wall nameOfMyApp.cpp -o nameOfMyApp
But I would just use the macro in TextMate
But it turns out that we need to output .o files that can be used for dynamic linking so check this out
http://www.arduino.cc/en/Hacking/LibraryTutorial

