That's what I was looking into some time ago. I was looking at an arduino doing the compiling and then programming another arduino.
I didn't get very far becuase I realised that that was rather out of my reach with limited knowledge (none) of the bootloader/chip architecture/arduino IDE etc.
I got as far as that you could make sketches to run on arduino but you would need something on the arduino to interpret it (bitlash or similar). Then you could change the code and run different programs at different times, create them on anything as long as you could save it as a text file on a microSD card (or any media that can be interfaced with an arduino). With the new arduino chips (on the mega etc) with a lot more space, bitlash (or similar) could be made so that it could run most commands that you would ever want to run on an arduino.
In theory, you could make your own program that could interpret C++ code and run it using a program on your arduino. Then you wouldn't need to compile it as a hex (or whatever the chip uses), you could have your arduino interpret it as it runs it. It would not be as fast as straight forward 'code' but for most things, that would not matter too much.
Anyone want to embark on a C++ interpreter version of bitlash with me?
It is a project on my list but I have been a bit busy recently and not had much chance to start on this (possibly massive) project.