float b = 0.0f;
cout<<(int)b<<endl; //0
cout<<(int&)b<<endl; //0 (int&)b?
cout<<((int)b==(int&)b)<<endl; //1
cout<<(int)b<<endl; //0
cout<<(int&)b<<endl; //0 (int&)b?
cout<<((int)b==(int&)b)<<endl; //1
float类型转换为int的输出结果
博客展示了将float类型变量b初始化为0.0f后,进行不同方式转换为int类型的输出情况。包括(int)b、(int&)b的输出,以及比较两者是否相等的结果。

被折叠的 条评论
为什么被折叠?