本质上我是在写一个简短的脚本。最简单的查看方式是它适用于具有资源收集的游戏。 ResGain 是获得的资源,BonusGain 是获得额外资源的机会。我收到 ResGain 和 Bonus Gain 函数的 Identifier not found 错误,但我已经在 main 之前声明了 ResGain 和 BonusGain 函数。有什么想法吗?
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
float ResGain(float u, int r) //calc Base resource Gain
{
float lapout;
lapout = r * u;
return (lapout);
}
char BonusGain(int b) //Determines if a bonus material would be produced.
{
char bonus;
int rng;
rng = rand() % 100 + 1;
if (rng <= b)
bonus = 1;
return(bonus);
}
int main()
{
float l;
l = ResGain(1.1,70);
cout << "You have earned" << l << "Lapis";
if (BonusGain(3)==1)
cout << "You have also earned a bonus material";
system("pause");
return 0;
}
最佳答案
很可能未找到的标识符是 system()
,它不是标准库的一部分。您应该在声明的位置找到特定于 Windows 的 header 。
关于c++ - 错误 C3861 : 'ResGain' : identifier not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19580836/