I have the following templated classes,
template <typename Real>
class Marker {
typedef Wm5::Vector3<Real> Position ;
typedef Wm5::Vector3<Real> Normal ;
typedef Wm5::Vector3<Real> Color ;
public:
Marker(int id = -1, Position position = Wm5::Vector3<Real>::ZERO, Normal normal = Wm5::Vector3<Real>::ZERO, Color color = Wm5::Vector3<Real>::ZERO)
: id_(id), position_(position), normal_(normal), color_(color), cluster_(-1) {}
~Marker() {}
private:
int id_ ;
Position position_ ;
Normal normal_ ;
Color color_ ;
int cluster_ ;
};
template <typename T>
class MarkerSet {
typedef Marker<T> MarkerT ;
typedef std::vector<MarkerT> MarkerVector ;
public:
MarkerSet::MarkerSet(int id = -1, MarkerVector markers = MarkerVector())
{id_ = id; markers_ = markers;}
MarkerSet::~MarkerSet() {}
private:
int id_ ;
MarkerVector markers_ ;
} ;
When I try to create a MarkerSet object by
MarkerSet<double> markerSet ;
Getting this linker error,
error LNK2001: unresolved external symbol "public: __thiscall MarkerSet<double>::MarkerSet<double>(int,class std::vector<class Marker<double>,class std::allocator<class Marker<double> > >)" (??0?$MarkerSet@N@@QAE@HV?$vector@V?$Marker@N@@V?$allocator@V?$Marker@N@@@std@@@std@@@Z)
I would be extremely grateful if somebody could give me a pointer in the right direction with regards to what I have done wrong.
Edit:
Ok I have narrowed it down to something rather odd.
in .h
MarkerSet(int id = -1, MarkerVector markers = MarkerVector())
{id_ = id; markers_ = markers;}
builds fine
Rather than in .h
MarkerSet(int id = -1, MarkerVector markers = MarkerVector()) ;
in .cpp
template <typename T>
MarkerSet<T>::MarkerSet(int id, MarkerVector markers) {
id_ = id ;
markers_ = markers ;
}
Errors out in the way described above.
Any thoughts?