rewrite c++