错误C3861:'ResGain':找不到标识符

时间:2013-10-25 03:57:18

标签: c++ visual-studio undeclared-identifier

基本上我正在编写一个简短的脚本。最简单的方法是使用资源集合进行游戏。 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;
}

1 个答案:

答案 0 :(得分:0)

很可能找不到的标识符是system(),它不是标准库的一部分。您应该在声明它的位置找到特定于Windows的标头。