Convert jiim.c to C++