Converted reflection code from c to c++