【问题标题】:Too many types in declaration C++声明 C++ 中的类型太多
【发布时间】:2015-06-28 09:27:48
【问题描述】:

unsigned/signed long int a; 是可能的 为什么 unsigned/signed long float/double a; 是不可能的?

为什么我得到 too many types in declaration 错误,后者而不是前者?

【问题讨论】:

  • 因为没有无符号浮点数?
  • error: 'signed' or 'unsigned' invalid for 'a' & error: 'long' invalid for 'a'

标签: c++ variables modifiers


【解决方案1】:

共有三种浮点类型:floatdoublelong double。这些都没有无符号等价物,因此将signedunsigned 放在它们前面是无效的。没有long float这样的类型。

【讨论】:

    【解决方案2】:

    您收到该消息是因为存在 long double,但 unsigned long double 不存在。 unsigned 也可以解释为 int,因此您在后一个声明中拥有两种类型:unsignedlong double。我不相信 C++ 中有很长的浮点数。

    【讨论】:

      【解决方案3】:

      这是因为第一个 (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     
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多