add set function for cpp generated code