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