4
請問任何人,請解釋可能導致此錯誤的原因?錯誤:無效的基類C++
Error: Invalid base class
我有其中一人是從第二派生兩類:
#if !defined(_CGROUND_H)
#define _CGROUND_H
#include "stdafx.h"
#include "CGameObject.h"
class CGround : public CGameObject // CGameObject is said to be "invalid base class"
{
private:
bool m_bBlocked;
bool m_bFluid;
bool m_bWalkable;
public:
bool draw();
CGround();
CGround(int id, std::string name, std::string description, std::string graphics[], bool bBlocked, bool bFluid, bool bWalkable);
~CGround(void);
};
#endif //_CGROUND_H
而且CGameObject看起來是這樣的:
#if !defined(_CGAMEOBJECT_H)
#define _CGAMEOBJECT_H
#include "stdafx.h"
class CGameObject
{
protected:
int m_id;
std::string m_name;
std::string m_description;
std::string m_graphics[];
public:
virtual bool draw();
CGameObject() {}
CGameObject(int id, std::string name, std::string description, std::string graphics) {}
virtual ~CGameObject(void);
};
#endif //_CGAMEOBJECT_H
我試圖清理我的項目,但徒勞。
猜測,但'std :: string m_graphics [];'不是標準的C++。如果它意味着我認爲它的意思,那麼它會造成一個無效的基類。我建議用'std :: vector m_graphics;'替換。 –
john
@john m_graphics []是完全有效的標準C++。 –
@john它幫助,謝謝。請把它作爲anwser輸入,我會將其標記爲最好的。 :) – dziwna