error in cpp snippet