在菜单调用模式对话框,要判断对话框里的成员变量,为什么会出现这样的警告?怎样解决?
warning C4805: '==' : unsafe mix of type 'int' and type 'const bool' in operation代码如下:
if(LoginDlg.DoModal()==IDOK){
if(LoginDlg.m_bLegal==true){问题就出在这里,难道int和bool不能放在一起比较?

解决方案 »

  1.   

    Compiler Warning (level 1) C4805
    'operation' : unsafe mix of type 'type' and type 'type' in operationThis message is similar to C4804, and it is limited to binary operations. It is generated for operations such as b &= i, b+=i, b/=b, b%=i, etc., where b and i are bool and int respectively .用TRUE代替true.
      

  2.   

    BOOL类型实际是int类型。
    你将int型和bool类型比较,当然会给出类型不安全警告。使用的时候应该按照这样配对使用:BOOL : TRUE, FALSE
    bool : true, false