Convert loadfile.c to C++