Convert the xpt code to C++