使用GetStatus对停止枚举值编译错误

Compiler error on Stopped enum value using GetStatus

本文关键字:编译 错误 枚举 GetStatus 使用      更新时间:2023-10-16

我试图获得声音效果的状态,但我不知道如何实际找出状态是什么。我对c++还是个新手。我试着去阅读关于枚举的资料,并应用我所看到的,但它不起作用。这是我的代码

sf::Sound::Status BeepStatus = Beep.GetStatus();
cout << BeepStatus;
if (BeepStatus == Stopped)
{
    Beep.SetPitch(float((rand()%15)-1)/10);
    Beep.Play();
}

这段代码不能工作。在编译过程中,它会说未定义Stopped。我该怎么办?

您需要为您的Stopped变量使用作用域操作符。

很可能是这样的:

sf::Sound::Stopped