Right I am getting weird linker errors which I've never seen before and which I can't really decipher.
Code for the RelationOwner
and RelationUser
can be found there. One remark: I've moved all function bodies to the source file instead of the header file. Naming has stayed the same.
Error 1 error LNK2019: unresolved external symbol "public: __thiscall RelationUser<class Family,class Citizen>::RelationUser<class Family,class Citizen>(class Family *)" (??0?$RelationUser@VFamily@@VCitizen@@@@QAE@PAVFamily@@@Z) referenced in function "public: __thiscall Citizen::Citizen(class Family &,class Name)" (??0Citizen@@QAE@AAVFamily@@VName@@@Z) *path*\Citizen.obj CodeAITesting
Error 2 error LNK2019: unresolved external symbol "public: __thiscall RelationUser<class Family,class Citizen>::~RelationUser<class Family,class Citizen>(void)" (??1?$RelationUser@VFamily@@VCitizen@@@@QAE@XZ) referenced in function __unwindfunclet$??0Citizen@@QAE@AAVFamily@@VName@@@Z$1 *path*\Citizen.obj CodeAITesting
Error 3 error LNK2019: unresolved external symbol "public: __thiscall RelationOwner<class Family,class Citizen>::~RelationOwner<class Family,class Citizen>(void)" (??1?$RelationOwner@VFamily@@VCitizen@@@@QAE@XZ) referenced in function __unwindfunclet$??0Family@@QAE@VName@@@Z$1 *path*\Family.obj CodeAITesting
The first one is about a constructor and the second two are about the destructor. That I understand.
I've also implemented my own version of the User
and Owner
as the following:
// header of Family.h (Owner in the linked PDF file)
#include "Name.h"
#include "RelationOwner.h"
class Citizen;
class Family; // I didn't really know if this one was necessary.
class Family
: public RelationOwner<Family, Citizen>
{
public:
Family(Name name);
private:
Name name;
};
// Source of Family.cpp
#include "Name.h"
Family::Family(Name name)
: name(name)
{
}
//Source of Citizen.h (User in the linked PDF)
#include "Name.h"
#include "RelationUser.h"
class Citizen;
class Family;
class Citizen
: public RelationUser<Family, Citizen>
{
public:
Citizen(Family &family, Name name);
private:
Name name;
};
// Source of Citizen.cpp
#include "Family.h"
#include "Name.h"
#include "RelationUser.h"
Citizen::Citizen(Family &family, Name name)
: RelationUser<Family, Citizen>(&family),
name(name)
{
}
As far as I know I am not doing anything fancypancy, yet it is complaining big time and I don't know why.