Lemme try and give an example of the sort of commands you might have to use under kubuntu. The process'll be a littel different with knoppix, but most of the commands should be the same
(Replace # with partition number with code on it; umask specifies that normal users have read privs, writing to NTFS not supported under Linux)
(~ is a symbol standing for your home directory. i have no idea if knoppix ramdisk will have enough space for copying the code, if not you may have to save only intermediate and output files to /home...something i won't go into)
cd ~
mkdir code_temp
cd /media
sudo mkdir code_drive
sudo mount /dev/hda# code_drive -o umask=022
cd code_drive
cd directory/with/code/in/it
cp -R *.* ~/code_temp
cd ~/code_temp
g++ -o program_name *.cpp
All that assumes, in addition to the above stuff, that the program doesn't need any special libs or compile options.
Your best bet, though, would be to set up a 5-10 GB partition and install linux on that, so you could mount stuff on boot and wouldn't have to go through the above every time, could install other programs besides the default knoppix ones, etc etc