Search code examples
c++inheritancelinker-errorslnk2019

LNK2019 When trying to inherit a class


So, I'm trying to inherit a class from another. I have the base class Entity and I have a Hero class that needs to be inherited from it.

Like usual, I do this like this:

#include "Entity.h"

class Hero : public Entity
{
public:
    Hero(Sprite* sprite_, Scene* scene, float xPosition, float yPosition, const char* name);
    ~Hero(void);
};

My entity class:

#include "Sprite.h"
#include <vector>
#include "Scene.h"

class Entity
{
public:
    Entity(void);
    Entity(Sprite* Sprite_);
    Entity(Sprite* Sprite_, Scene* scene, float xPosition, float yPosition, const char*);
    ~Entity(void);
}

And the erorr I get is:

1>Hero.obj : error LNK2019: unresolved external symbol "public: __thiscall Entity::Entity(void)" (??0Entity@@QAE@XZ) referenced in function "public: __thiscall Hero::Hero(class Sprite *,class Scene *,float,float,char const *)" (??0Hero@@QAE@PAVSprite@@PAVScene@@MMPBD@Z)

Could anyone tell me what I'm doing wrong here?


Solution

  • You're missing an implementation for Entity::Entity(void);