[38.10] GNU C++ (g++) produces big executables for tiny programs; Why?
libg++ (the library used by g++) was probably compiled with debug info
(-g). On some machines, recompiling libg++ without debugging can save
lots of disk space (approximately 1 MB; the down-side: you'll be unable to
trace into libg++ calls). Merely strip-ping the executable doesn't
reclaim as much as recompiling without -g followed by subsequent
strip-ping the resultant a.out's.
Use size a.out to see how big the program code and data segments really
are, rather than ls -s a.out which includes the symbol table.