fixed ref problem in cpp assignment