P
PyongHopscotch
Hi All,
So I'm getting the generic linker error (unresolved external
error) in VC 7.0 when I define a templatized function. Here's some
code examples:
template <class T>
class Diploid2DArrayAlleleGenome : public GA2DArrayAlleleGenome<T> {
public:
Diploid2DArrayAlleleGenome(unsigned int x, unsigned int y,
const GAAlleleSet<T> & a,
GAGenome::Evaluator f=(GAGenome::Evaluator)0,
void * u=(void *)0) :
GA2DArrayAlleleGenome<T>(x, y, a, f, u)
{};
virtual ~Diploid2DArrayAlleleGenome() {};
static int FlipMutator(GAGenome & c, float pmut);
};
I'm using GAlib btw.
If I define the function FlipMutator here in the class declaration then
it works fine, but if I do this:
template <class T> int
Diploid2DArrayAlleleGenome<T>::FlipMutator(GAGenome & c, float pmut) {
... code
};
I get the unresolved external, but If I change <T> to the type of the
calling function (e.g. <int>) then it works fine, but of course isn't
polymorphic on type. Any ideas? Am I doing this right?
-Thanks
So I'm getting the generic linker error (unresolved external
error) in VC 7.0 when I define a templatized function. Here's some
code examples:
template <class T>
class Diploid2DArrayAlleleGenome : public GA2DArrayAlleleGenome<T> {
public:
Diploid2DArrayAlleleGenome(unsigned int x, unsigned int y,
const GAAlleleSet<T> & a,
GAGenome::Evaluator f=(GAGenome::Evaluator)0,
void * u=(void *)0) :
GA2DArrayAlleleGenome<T>(x, y, a, f, u)
{};
virtual ~Diploid2DArrayAlleleGenome() {};
static int FlipMutator(GAGenome & c, float pmut);
};
I'm using GAlib btw.
If I define the function FlipMutator here in the class declaration then
it works fine, but if I do this:
template <class T> int
Diploid2DArrayAlleleGenome<T>::FlipMutator(GAGenome & c, float pmut) {
... code
};
I get the unresolved external, but If I change <T> to the type of the
calling function (e.g. <int>) then it works fine, but of course isn't
polymorphic on type. Any ideas? Am I doing this right?
-Thanks