Convert editpal.c to C++