【问题标题】:Error C3861: 'ResGain': identifier not found错误 C3861:“ResGain”:未找到标识符
【发布时间】:2013-10-25 03:57:17
【问题描述】:

基本上我正在写一个简短的脚本。最简单的查看方法是它是针对具有资源集合的游戏。 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;
}

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2013-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-01
      相关资源
      最近更新 更多