C++ でスーパー クラス内のサブクラスを参照する際に少し混乱しています。たとえば、指定された Java :
public class Entity {
protected ComplexEntity _ce;
public Entity() {
}
public ComplexEntity getCentity() {
return _ce;
}
}
ComplexEntityがエンティティを拡張する場所.それは機能します.サブクラスでは、getCentity()を呼び出しますエラーはありません.
今、私がそのようなものを書くとき、C++で:
#pragma once
#include "maininclude.h"
#include "ExtendedEntity.h"
using namespace std;
class EntityBase
{
public:
EntityBase(void);
EntityBase(const string &name);
~EntityBase(void);
protected:
ExtendedEntity* _extc;
string _name;
};
コンパイラ エラーが発生しています:
error C2504: 'Entity' : base class undefined
このエンティティから継承するクラスでは、なぜそれが起こるのですか?
C ++では完全に受け入れられませんか?
エンティティは抽象でなければなりませんか?可能な回避策についての提案を得たいと思います。