遇到"identifier not found"问题

Having issue with "identifier not found"

本文关键字:问题 found identifier 遇到 not      更新时间:2023-10-16

我正在学习c++,我得到"process_teleport_menu"标识符未找到"错误,我知道在C中,一切都必须在使用前声明。这是一段代码:

if (bDown)
        {
            menu_beep();
            activeLineIndexPlayer2++;
            if (activeLineIndexPlayer2 == lineCount)
                activeLineIndexPlayer2 = 0;
            waitTime = 150;
        }else
        if (bRight)
        {                                  
            menu_beep();                     
            if (activeLineIndexPlayer2 = process_teleport_menu())  //Error
                activeLineIndexPlayer2 = 0;
        }
    }
    return false;
}
int teleportActiveLineIndex = 0;
bool process_teleport_menu()
{
    const float lineWidth = 250.0;
    const int lineCount = 17;

还有别的办法吗?

在声明process_teleport_menu()函数之前使用它。您可以在定义函数之前声明它,以便在使用它之前指出它的存在:将bool process_teleport_menu();放在包含麻烦代码的函数之前,这样应该可以工作,除非它不是您的全部问题。

然而,这个问题在大多数c++教程中都有答案,所以请在提出另一个基本问题之前先阅读一篇。