Corrections to c++ code for compiling