Can you rewrite the code in c++?