This question already has an answer here:
I'm having inconsistent linker errors when trying to build my c++11 project in Visual Studio 2017.
I call them inconsistent primarily because they only happen now and then, forcing me to rebuild the entire project to get rid of them.
The equivalent pseudo-code is:
// Base.h
class Base
{
public:
template <class Derived>
static Derived* create()
{
Derived* d = new Derived();
d->foo = 10;
d->bar = 15;
return d;
}
~Base()
{
//
}
virtual void initialize() = 0;
virtual void draw() = 0;
virtual void update() = 0;
protected:
Base()
{
//
}
}
// Inheritor.h
class Inheritor : public Base
{
public:
~Inheritor()
{
//
}
virtual void initialize() override; // implemented on Inheritor.cpp
virtual void draw() override; // implemented on Inheritor.cpp
virtual void update() override; // implemented on Inheritor.cpp
}
The linker errors are related with the pure virtual methods in Base
, but I don't understand what could be wrong, since I'm implementing everything in the Inheritor
class.
Error LNK2001 unresolved external symbol "public: virtual void __cdecl Inheritor::initialize(void)" (?initialize@Inheritor@@UEAAXXZ) canvas.obj 1
Error LNK2001 unresolved external symbol "public: virtual void __cdecl Inheritor::draw()" (?draw@Inheritor@@UEAAXXZ) canvas.obj 1
Error LNK2001 unresolved external symbol "public: virtual void __cdecl Inheritor::update(void)" (?update@Inheritor@@UEAAXXZ) canvas.obj 1
Aucun commentaire:
Enregistrer un commentaire