-
[RESOLVED] Linker Error
Hello all, i would appreciate it if anyone could enlighten me on a linker error.
First off the error
Code:
Error 1 error LNK2019: unresolved external symbol "public: __thiscall ReachTop<class Character>::ReachTop<class Character>(class Character *)" (??0?$ReachTop@VCharacter@@@@QAE@PAVCharacter@@@Z) referenced in function "void __cdecl `dynamic initializer for 'gReachTop''(void)" (??__EgReachTop@@YAXXZ) Main.obj DecisionTest
Reach Top class inherits from Goal Class
Goal Class
Code:
#ifndef _GOAL_H
#define _GOAL_H
#include "Action.h"
#include <list>
template <class T>
class Goal
{
public:
Goal(T* pOwner) : mpOwner(pOwner) {}
virtual ~Goal() {}
virtual float CalculateDesirability() = 0;
virtual Action<T>* CreateAction() = 0;
protected:
T* mpOwner;
};
template <class T>
struct GoalList
{
typedef std::list<Goal<T>*> Type;
};
#endif
ReachTop Class Header
Code:
#ifndef _REACHTOP_H
#define _REACHTOP_H
#include <AI.h>
#include <SGE.h>
using namespace SGE;
template <typename T>
class ReachTop : public Goal<T>
{
public:
ReachTop<T>(T* pOwner);
virtual ~ReachTop() {}
virtual float CalculateDesirability();
virtual Action<T>* CreateAction();
protected:
T* mpOwner;
};
#endif
Reachtop class cpp
Code:
#include "ReachTop.h"
template <typename T>
ReachTop<T>::ReachTop(T* pOwner)
: mpOwner(pOwner)
{
}
template <typename T>
float ReachTop<T>::CalculateDesirability()
{
}
template <typename T>
Action<T>* ReachTop<T>::CreateAction()
{
}
Code to create
Code:
Character* gCharacter = new Character(1, gWorld);
Goal<Character>* gReachTop = new ReachTop<Character>(gCharacter);
Any ideas? I can provide the character class and its inheritance aswell if you like.
-
Re: Linker Error
-
Re: Linker Error
I tried a inline file before and i just got
Code:
error C2512: 'Goal<T>' : no appropriate default constructor available
1> with
1> [
1> T=Character
1> ]
1> *\reachtop.h(13) : while compiling class template member function 'ReachTop<T>::ReachTop(T *)'
1> with
1> [
1> T=Character
1> ]
1> *\main.cpp(14) : see reference to class template instantiation 'ReachTop<T>' being compiled
1> with
1> [
1> T=Character
1> ]
instead
-
Re: Linker Error
C2512 Since you've provided a constructor that takes a parameter, you must provide a default constructor as well (a constructor taking no parameters). The compiler will not automatically create one in these cases.
Viggy
-
Re: Linker Error
I tried providing that already aswell. Same error.
[Edit]
Nevermind i added one to goal aswell and it fixed it. Thank you both.