Error LNK2019 unresolved virtual class of external characters

I know that this question has been asked several times, but I do not know how to solve it.

I get this error when I try to build my project:

error LNK2019: unresolved external symbol "public: virtual __thiscall IGameState::~IGameState(void)" ( ??1IGameState@ @ UAE@XZ ) in function "public: virtual __thiscall MenuState::~MenuState(void)" ( ??1MenuState@ @ UAE@XZ ) 

Here is my code:

IGameState.h

 class IGameState { public: virtual ~IGameState(); virtual void update() = 0; virtual void render() = 0; }; 

MenuState.h

 #include "IGameState.h" class MenuState : public IGameState { public: MenuState(); ~MenuState(); void update(); void render(); }; 

MenuState.cpp

 #include "MenuState.h" #pragma region Constructor MenuState::MenuState() { } MenuState::~MenuState() { } #pragma endregion void MenuState::render() { } void MenuState::update() { } 

What happened to the destructor? Thanks.

+4
source share
1 answer

The error message reports a communication error since you did not implement ~IGameState() . Try adding the code below:

 class IGameState { public: virtual ~IGameState() {} //^^^^ define it virtual void update() = 0; virtual void render() = 0; }; 
+6
source

Source: https://habr.com/ru/post/1487850/


All Articles