I have class Foo defined as such:
foo.h:
class Foo
{
public:
Foo() {}
~Foo() {}
double Compute1(const double& n) const;
template<int Dim>
double Compute2(const double& n) const;
};
foo.cpp:
double Foo::Compute1(const double& n) const
{
return Compute2<3>(n);
}
template<int Dim>
double Foo::Compute2(const double& n) const
{
return pow(n, Dim);
}
I think that Compute2 has been specialized with Dim=3 when it is called by Compute1. But when I called:
Foo comp;
double a = comp.Compute2<3>(10.0);
The compiler said that
undefined reference to `double Foo::Compute2<3>(double const&) const'
What am I wrong in this case?