【问题标题】:when c++ return true / false if the data type is integer or double value如果数据类型是整数或双精度值,c++ 返回真/假
【发布时间】:2014-12-03 01:17:37
【问题描述】:

我们正在将项目从 c++ 迁移到 c#。谁能告诉我什么时候 c++ 为整数或双精度数据类型值返回 true 或 false。

int a=3; or int a=-3; ... etc

if(a) //it will return true or false
{

}
else
{

}

【问题讨论】:

标签: c++


【解决方案1】:

对于0,它返回false,否则返回true

【讨论】:

    【解决方案2】:

    如果变量不为零,则返回true

    int a = 3; //or any negetive number like a = -3
    
    if(a){
    //This part will execute
    }
    else
    {
    
    }
    

    第二部分:

    int a = 0;
    if(a){
    
    }
    else
    {
    //this part will execute
    }
    

    【讨论】:

      猜你喜欢
      • 2019-10-19
      • 1970-01-01
      • 2017-10-12
      • 2021-06-24
      • 2013-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-13
      相关资源
      最近更新 更多