错误显式类型缺失(假定为整数)
error explicit type is missing('int assumed')
>我在我的项目中收到此错误,但我似乎无法弄清楚,错误是
缺少错误显式类型(假定为 int)
这就是我所拥有的;
船.cpp
Ship::Ship(){
rot = 0;
position.x = SCREEN_WIDTH / 2;
position.y = SCREEN_HEIGHT / 2;
velocity.x = .2;
velocity.y = .2;
radius = 0;
}
float Ship::&rotateLeft(){
if (rot < 0)
rot += 360;
rot-= velocity.x;
return rot;
}
float Ship::&rotateRight(){
if (rot > 360)
rot -= 360;
rot+= velocity.x;
return rot;
}
float Ship::&getRot(){
return rot;
}
船.h
#include "Physics.h"
class Ship : public Physics{
private:
float rot;
public:
float radius;
XMFLOAT2 size;
Ship();
float &rotateRight();
float &rotateLeft();
float &getRot();
};
物理.h
class Physics{
public:
XMFLOAT2 position;
XMFLOAT2 velocity;
};
这很奇怪,因为它告诉我在我的 rotateleft 函数中未定义腐烂和速度,但它在构造函数中没有抱怨。相同的函数也给了我错误显式类型丢失('int 假设')。
函数返回类型上的 & 符号应该在类名之前;即代替这个:
float Ship::&rotateLeft(){
。试试这个:
float & Ship::rotateLeft(){
相关文章:
- 整数类型应该显式转换(例如"int"到"无符号")还是只会增加混乱?
- 涉及旧式枚举和整数类型的重载解析
- 将字符串转换为整数类型T,检查是否存在溢出
- 整数文本太大,无法用任何整数类型表示--C++
- isdigit(c) - 字符或整数类型?
- 为什么对小于 4 个字节的整数类型的位操作会发生意外行为?
- C++模板专用化 - 将其他整数类型委托给uint64_t
- 何时应使用 C++ 固定宽度整数类型,它们如何影响性能?
- 根据浮点数选择最小整数类型
- 为什么 QVariant 将字符类型视为整数类型
- 我们可以在整数类型的双指针中分配2D整数数组的地址吗?怎么可能
- 默认情况下,决定整数类型是唱歌或无符号的类型
- 是否可以根据类型是整数类型还是浮点类型重载模板函数
- 使用固定整数类型的安全性
- 如何使用条件来检查类型名 T 是否是 C++ 中浮点类型的整数类型
- C++文本整数类型
- 哪种整数类型可以安全且便携式用于始终保持指针值
- 检测整数类型变量上的空白输入
- 为什么对Chrono :: Nanseconds的表示类型是签名的整数类型
- 如何处理警告:从较小的整数类型int转换为int*