Convert code to C++