Convert miscfrac.c to C++