我正在尝试创建以下类的实例:
#ifndef Sik_GameEntity_h
#define Sik_GameEntity_h
class GameEntity {
public:
~GameEntity(){};
void setup();
void update();
void draw();
void clear();
protected:
private:
};
#endif
这些方法中的每一个(减去解构器)都在我的 .cpp 文件中得到了充实。
for ( int i = 0; i < nEntities; i++ )
{
GameEntity ent;
ent.setup();
entities.push_back(ent);
}
我正在创建一个实例并将其插入到游戏实体对象的向量中。当我创建一个实例时,我从 XCode 收到以下错误:]
Undefined symbols for architecture i386:
"GameEntity::GameEntity()", referenced from:
appCore::setup() in appCore.o
"GameEntity::~GameEntity()", referenced from:
appCore::setup() in appCore.o
std::vector<GameEntity, std::allocator<GameEntity> >::_M_insert_aux(__gnu_cxx::__normal_iterator<GameEntity*, std::vector<GameEntity, std::allocator<GameEntity> > >, GameEntity const&) in appCore.o
void std::_Destroy<GameEntity>(GameEntity*) in appCore.o
"vtable for GameEntity", referenced from:
GameEntity::GameEntity(GameEntity const&) in appCore.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture i386
我试过添加一个构造函数,但没有任何区别,我仍然收到同样的错误。我在课堂上做错了什么很明显吗?
编辑:我忘了提,我清理了我的构建。