我在尝试编译时遇到标题错误。
#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;
}
这是我的完整代码,我试图让它输出 You win or You lose, 50-50
最佳答案
你正在比较函数指针
和一个integer(5)
,我猜你想调用chance()
函数,试试
if (chance() > 5)
^^
关于c++ - 错误 : Iso c++ forbids comparison between pointer and integer [c++],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18415404/