C++ 尝试创建类的实例会在XCode中引发vtable错误
我正在尝试创建以下类的实例:C++ 尝试创建类的实例会在XCode中引发vtable错误,c++,xcode,class,linker-errors,C++,Xcode,Class,Linker Errors,我正在尝试创建以下类的实例: #ifndef Sik_GameEntity_h #define Sik_GameEntity_h class GameEntity { public: ~GameEntity(){}; void setup(); void update(); void draw(); void clear(); protected: private: }; #e
#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);
}
for(int i=0;i
我正在创建一个实例,并将其插入到游戏实体对象的向量中。创建实例时,我从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
架构i386的未定义符号:
“GameEntity::GameEntity()”,引用自:
appCore.o中的appCore::setup()
“GameEntity::~GameEntity()”,引用自:
appCore.o中的appCore::setup()
appCore.o中的std::vector::_M_insert_aux(u gnu_cxx::u normal_迭代器,GameEntity const&)
void std:_在appCore.o中销毁(GameEntity*)
“游戏实体的vtable”,引用自:
GameEntity::appCore.o中的GameEntity(GameEntity常量&)
注意:缺少vtable通常意味着第一个非内联虚拟成员函数没有定义。
ld:未找到架构i386的符号
我试着添加一个构造函数,但是没有什么不同,我仍然收到相同的错误。我在课堂上做错了什么是显而易见的吗
编辑:
我忘了提到,我清理了我的构建。以下注释和错误意味着您正在尝试在cpp文件而不是头文件中内联构造函数或安装方法。删除cpp文件中的所有内联关键字
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture i386
发布您的appcore::setup()例程,其中包括您需要发布复制构造函数。