C++ type conversion fix