int'float'需要缩小转换

时间:2019-04-14 20:17:52

标签: c++

从type_1转换为type_2时出现转换编译器错误

CoordF character_coord() const { return character_coord_; };
void Set_character_coord(int x, int y) { character_coord_ = { x, y }; }; //line with error
void Set_character_coord(CoordF char_coord){ character_coord_ = char_coord; };

float vert_speed() const { return vert_speed_; };
void Set_vert_speed(float vert_speed) { vert_speed_ = vert_speed; };

camera_.Set_camera_coord({ screen_width_ / 2, screen_height_ / 2 }); //another example of same error 
camera_.Set_camera_size( screen_width_, screen_height_);

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:-2)

{}运算符表示您不想进行强制转换。使用()也许