c to c++ rewrite (the beginning)