相关疑难解决方法(0)

为什么要始终启用编译器警告?

我经常听到,在编译C和C ++程序时,我应该“始终启用编译器警告”。为什么这是必要的?我怎么做?

有时我也听说我应该“将警告视为错误”。我是不是该?我怎么做?

c c++ warnings c++-faq compiler-warnings

292
推荐指数
15
解决办法
3万
查看次数

为什么我们不能在C ++中进行三向比较?

概括一下,为什么不2 < x < 9等于2 < x && x < 9

这是我编写的测试代码:

#include <iostream>

int main()
{
    int nums[] = { 5 , 1, 10};

    // We are gonna check if the number is in the range 2 - 9 
    for (auto e : nums)
    {
        if (2 < e < 9)
            std::cout << "2 < " << e << " < 9" << std::endl;

        if(2 < e && e < 9)
            std::cout << "2 < …
Run Code Online (Sandbox Code Playgroud)

c++

18
推荐指数
2
解决办法
1888
查看次数

在比较三个浮点数时双重不等式

有人可以告诉我为什么以下不起作用?(我的意思是没有输出)

if(0.0001<0.001<0.01)   
    cout<<"hi\n"<<endl;
output:    (blank)
Run Code Online (Sandbox Code Playgroud)

虽然以下工作:

if(0.0001<0.001 && 0.001<0.01)  
    cout<<"hi\n"<<endl;
  output:hi
Run Code Online (Sandbox Code Playgroud)

c++ floating-point

1
推荐指数
1
解决办法
1361
查看次数

标签 统计

c++ ×3

c ×1

c++-faq ×1

compiler-warnings ×1

floating-point ×1

warnings ×1