c++ rewrite