c++ - 错误 C3861 : 'ResGain' : identifier not found

标签 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;
}

最佳答案

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

关于c++ - 错误 C3861 : 'ResGain' : identifier not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19580836/

相关文章:

javascript - 函数中未声明的 JavaScript 变量覆盖了使用

c++ - 如何在 Visual Studio 2012 中设置资源编辑器的网格大小?

c++ - 如何在 C++ 中对三元组进行排序?

visual-studio - 如何将 'long long'(或 __int64)转换为 __m64

c# - VSCT.exe 无法加载文件或程序集

c++ - 如何重建旧库以在最新的 Visual Studio 上工作?

c++运算符函数内未声明的标识符

c++ - 如何在另一个函数中使用这些变量?

c++ - 在 Windows 上以像素为单位获取 OpenGL 点大小?

c++ - 在不创建新子 vector 的情况下获取 vector 范围