当unsigned/signed long int a; 可能为什么unsigned/signed long float/double a; 不可能 ?
为什么我在后者的声明错误中得到太多类型而不是前者?
共有三种浮点类型float
:double
和long double
。这些都没有未签名的等价物,因此将signed
orunsigned
放在它们前面是无效的。没有这样的类型long float
。
您收到该消息是因为存在 long double,但 unsigned long double 不存在。unsigned 也可以被解释为一个 int,因此你在后一个声明中拥有两种类型:unsigned和long double。我不相信 C++ 中有很长的浮点数。
这是因为第一个 ( long int
) 是记录的变量类型,而第二个不是。
C++语言支持的数据类型有:
char
unsigned char
signed char
int
unsigned int
signed int
short int
unsigned short int
signed short int
long int
signed long int
unsigned long int
float
double
long double