S
StephQ
In utility.hpp I have:
namespace utility
{
template <class T, double (T::*F)(double) const>
class Display
{
private:
static double resolution;
static double margin;
public:
static void computePlot(stringstream& ss, const T& t, const
ClosedInterval& interval);
};
}
In utility.cpp:
#include <utility.hpp>
namespace utility
{
template <class T, double (T::*F)(double) const>
double Display<T,F>::resolution = 0.025;
template <class T, double (T::*F)(double) const>
double Display<T,F>::margin = 5;
}
Then I have another cpp file in which I'm including utility.hpp and
calling the computePlot function using:
utility:isplay<EnvelopePiece, &EnvelopePiece::f>::computePlot( ss,
*this, interval );
(the *this because I'm inside a member function of the EnvelopePiece
class when I'm calling computePlot)
However when compiling I get:
1>envelope.obj : error LNK2001: unresolved external symbol "private:
static double utility:isplay<class EnvelopePiece,&public: double
__thiscall EnvelopePiece::f(double)const >::resolution" (?resolution@?
$Display@VEnvelopePiece@@$1?f@1@QBENN@Z@utility@@0NA)
Like if the static variables were not declared.
But isn't double Display<T,F>::resolution the proper way to declare
the "generic" template static variable, that I can then specialize if
I want to?
Thanks
StephQ
namespace utility
{
template <class T, double (T::*F)(double) const>
class Display
{
private:
static double resolution;
static double margin;
public:
static void computePlot(stringstream& ss, const T& t, const
ClosedInterval& interval);
};
}
In utility.cpp:
#include <utility.hpp>
namespace utility
{
template <class T, double (T::*F)(double) const>
double Display<T,F>::resolution = 0.025;
template <class T, double (T::*F)(double) const>
double Display<T,F>::margin = 5;
}
Then I have another cpp file in which I'm including utility.hpp and
calling the computePlot function using:
utility:isplay<EnvelopePiece, &EnvelopePiece::f>::computePlot( ss,
*this, interval );
(the *this because I'm inside a member function of the EnvelopePiece
class when I'm calling computePlot)
However when compiling I get:
1>envelope.obj : error LNK2001: unresolved external symbol "private:
static double utility:isplay<class EnvelopePiece,&public: double
__thiscall EnvelopePiece::f(double)const >::resolution" (?resolution@?
$Display@VEnvelopePiece@@$1?f@1@QBENN@Z@utility@@0NA)
Like if the static variables were not declared.
But isn't double Display<T,F>::resolution the proper way to declare
the "generic" template static variable, that I can then specialize if
I want to?
Thanks
StephQ