refactoring to output c++ class