我正在做一個東西,今天我遇到了C2864錯誤。我是C 的新手,所以我實際上有點迷茫。
#ifndef MONSTER_ZOMBIE_H
#define MONSTER_ZOMBIE_H
//類定義
class CZombie : public CBaseMonster {
public:
virtual void Spawn(void) 。
virtual void Precache(void);
virtual void HandleAnimEvent(MonsterEvent_t *pEvent);
virtual void PainSound(void) ;
virtual void DeathSound(void);
virtual void AlertSound(void);
virtual void IdleSound(void);
virtual void AttackSound(void);
virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType>。
virtual bool CheckRangeAttack1(float flDot, float flDist) { return false; }
virtual bool CheckRangeAttack2(float flDot, float flDist) { return false; }
virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType>;
virtual int IgnoreConditions(void);
virtual int Classify(void);
virtual int Save(CSave &save)。
virtual int Restore(CRestore & restore);
static TYPEDESCRIPTION m_SaveData[]。
static const char *pAttackSounds[];
static const char *pIdleSounds[];
static const char *pAlertSounds[];
static const char *pPainSounds[];
static const char *pDeathSounds[];
static const char *pAttackHitSounds[];
static const char *pAttackMissSounds[];
protected:
BOOL m_flDebug = false;
float m_flBulletDR = 0.0;
float m_flNextFlinch;
float m_flHitgroupHead;
float m_flHitgroupChest;
float m_flHitgroupStomach;
float m_flHitgroupArm;
float m_flHitgroupLeg;
float m_flDmgOneSlash;
float m_flDmgBothSlash;
};
#endif // MONSTER_ZOMBIE_H
Visual Studio說,BOOL m_flDebug = false;和float m_flBulletDR = 0.0;是錯誤的原因,但我實在不知道如何解決這個問題。 我所嘗試的是將這兩行移出 "protected:",之后代碼實際上是可以編譯的,但所說的僵尸只是變得無懈可擊了 我看了看這里的類似問題,但沒有從那里的解釋中真正學到任何東西
。uj5u.com熱心網友回復:
你所嘗試的代碼只有在C 11中才是合法的。 因此,改變你的編譯器選項,至少是C 11(不確定這在Visual Studio 2010中是否可行,你真的應該升級你的編譯器)。
或者用建構式的老方法來做事。
class CZombie : public CBaseMonster {
public:
CZombie() : m_flDebug(false), m_flBulletDR(0。 0) {}
...
};
如果你真的不知道建構式,那么你的C 知識中存在著一些嚴重的漏洞。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/317261.html
標籤:
