I've searched through the many unresolved external symbol (lnk2019) problems on the SO and most of them were problems where someone forgot to put a constructor definition in a .cpp file or some .cpp file was not included in the building problem.
The Linker gives me some errors saying i have an unresolved external:
//error was on NotationInstrument.obj
iNotationInstrument<class Notation::NotationTrack>::~iNotationInstrument<class
Notation::NotationTrack>
(I also got some LNK2001 erros as well. It is another 'unresolved external symbol' error)
Yet this destructor IS defined. Since it's the destructor of an interface, the derived class (NotationInstrument) have a destructor that overrides the base's destructor. And NotationInstrument destructor is defined.
NotationInstrument.h
#include "iNotationInstrument.h"
#include "NotationTrack.h"
#include <vector>
namespace Notation
{
class NotationInstrument : public iNotationInstrument<NotationTrack>
{
public:
NotationInstrument();
~NotationInstrument();
std::vector<NotationTrack> getTracks() override ;
private:
std::vector<NotationTrack> tracks;
}; // end of class "NotationInstrument"
};
NotationInstrument.cpp
#include "NotationInstrument.h"
//i've included the following just to be sure (for now, while debuggin)
#include "iNotationInstrument.h"
#include "iNotationTrack.h"
#include "NotationTrack.h"
namespace Notation
{
NotationInstrument::NotationInstrument(){}
NotationInstrument::~NotationInstrument(){}; //here is the destructor
std::vector<NotationTrack> NotationInstrument::getTracks()
{
return tracks;
};
};
iNotationInstrument.cpp
#include <vector>
template <class NotationTrackTemplate>
class iNotationInstrument
{
public:
//iNotationInstrument();
virtual ~iNotationInstrument() =0 ;
private:
virtual std::vector<NotationTrackTemplate> getTracks() =0 ;
};
Following other SO questions about linker erros, i've checked to make sure all the related files are included in the build.
(I didn't posted NotationTrack.h/.cpp and iNotationTrack.h to keep the question to a minimum. But i can post them if you want.)
Question: If ~NotationInstrument() overrides ~iNotationInstrument() and it's declared and defined, why i'm getting this linker error?
Edit about this beeing a duplicate: I've already read more than 20 posts about this unresolved external error on SO. But still i can't understand why i'm getting an unresolved external for something that i think is defined. I know i'm wrong because i'm getting this erros. I just can't find why. I tried Matthew James Briggs's answer, but i get the same errors.