1

クラスを作成しましたAdresy

class Adresy {
    public:
        static const DWORD hp = 0x947000;
        static const DWORD mp = 0x7B2084;
        static const DWORD cap = 0x97EE94;
        enum Flags
        {
            None = 0,
            Poisoned = 1,
            Burning = 2,
            ProtectedByMagicShield = 16
        };
};

この例で使用しようとすると、次のようになります。

if(( (DWORD) adr.ProtectedByMagicShield & pFlags) == (DWORD) ProtectedByMagicShield){
//...
}

エラーをスローすると表示されます。'ProtectedByMagicShield' : undeclared identifier...

pFlagsは、DWORDC++。NETを使用しています。

4

1 に答える 1

5
if(( (DWORD) Adresy::ProtectedByMagicShield & pFlags) == (DWORD) Adresy::ProtectedByMagicShield){
    //...
}

列挙型の値にアクセスするには、クラス名とスコープトークン(::)を使用する必要があります。

これは、列挙型がクラスの特定のインスタンスではなく、静的constメンバーのようにクラス自体によって所有されているためです。

于 2012-07-06T19:27:59.227 に答える