Convert miscovl.c to C++