change C code to C++,move some var to class