警告为:
warning C4305: 'initializing' : truncation from 'const double' to 'float'不知道是什么原因
同样程序在borland c++ 3.1 for win中一切正常

解决方案 »

  1.   

    我也遇见过,不过没怎么查为什么.我都是强制转换了下:).是不是因为float后面的小数都要填上的原因呢?
      

  2.   

    Compiler Warning (level 1) C4305
    'identifier' : truncation from 'type1' to 'type2'The specified identifier type was converted to a smaller type. Information was lost in the casting.
      

  3.   

    这个是基础,应该写成:
    float a = 4.1f;    // 注意有字母f在C++里,默认的小数类型是double,出现const是因为4.1是一个常数。
      

  4.   

    这是由于编译器会将浮点常量默认地看作double,所以将会出现截断的警告。
    为了避免警告,你可以将这个常量显式声明为float常量:
    float a = 4.1f;
      

  5.   

    缺省是double类型
    应该是float a = 4.1f;