you don't write script files in c++, c++ is a programming langauge, not a scripting language. the example script that unspawn gave nearly does what you asked, to convert it to send the mail when you load, you should place it in etc/rc.d/rc3.d/S99<scriptname> (or 5 if you boot to X) instead of rc6.d, and also change what runlevel you are checking for (i.e. 3 or 5 instead of 6).
you might prefer a simpler approach however (sending a mail on reboot is slightly more complex...) you can just add a simple line such as:
/bin/true | mail -s "Boot at $(/bin/date)" <address@domain>
to the end of a start up script such as /etc/rc.local but naturally that is less rigorous than the previous example, and not as elegant either.