If you want to see some epub code in C++, then you should take a look at
Sigil, which is GPL'd and should be fine for your use.
Sigil, of course, is a large editing project. The bits you'll want to examine are in the Exporters directory, which has code showing how to construct the NCX and OPF files you need. As frabjous said, the rest is just zipping up the component files and setting the mimetype (which must
not be compresssed).