错误:iso c ++禁止指针和整数之间的比较[c ++]

时间:2013-08-24 05:51:53

标签: c++ function pointers codeblocks

我在尝试编译时遇到标题错误。

#include <iostream>
using namespace std;

int chance()
{
return rand()%11;
}

int main()
{
if (chance > 5)
    cout << "You win." << endl;
else
    cout << "You lose." << endl;
return 0;
}

这是我的完整代码,我试图让它输出你赢了或输了,50-50

1 个答案:

答案 0 :(得分:5)

您正在将function pointerinteger(5)进行比较,我想您想调用chance()函数,请尝试

if (chance() > 5)
          ^^