J
Joseph Paterson
Hi all,
I'm having some trouble with templates. I've read up some FAQs, but
still cannot seem to find the source of my problem!
I have three files: Bezier.h, Bezier.cpp and main.cpp.
Here are stripped down versions:
--- Bezier.h---
emplate <typename T = f32>
class Bezier
{
public:
static array< vector3<T> > *
GenerateBezierCurve(const array<vector3<T> >& cpoints, int
numpoints);
};
--- Bezier.h---
---Bezier.cpp---
template <typename T>
array< vector3<T> > *
Bezier<T>::GenerateBezierCurve(const array< vector3<T> >& cpoints,
int numpoints)
{
array< vector3<T> > * points = new array< vector3<T> >(numpoints);
T time = 0.0;
T time_increment = 1.0 / numpoints;
while (time < 0.0)
{
points->add(PointOnCurve(cpoints, time)); //
time += time_increment;
}
return points;
}
---Bezier.cpp---
---main.cpp---
array< vector3<float> > cpoints;
cpoints.push_back(vector3<float>(0.0f, 0.0f, 0.0f));
cpoints.push_back(vector3<float>(1.0f, 0.0f, 0.0f));
cpoints.push_back(vector3<float>(1.0f, 1.0f, 0.0f));
array< vector3<float> > * points =
Bezier<float>::GenerateBezierCurve(cpoints, 100);
---main.cpp---
It all compiles fine, but won't link:
main.cpp:: undefined reference to
`Bezier<float>::GenerateBezierCurve(array<vector3<float> > const&,
int)
Any help would be greatly appreciated!
Thanks,
Joseph Paterson
I'm having some trouble with templates. I've read up some FAQs, but
still cannot seem to find the source of my problem!
I have three files: Bezier.h, Bezier.cpp and main.cpp.
Here are stripped down versions:
--- Bezier.h---
emplate <typename T = f32>
class Bezier
{
public:
static array< vector3<T> > *
GenerateBezierCurve(const array<vector3<T> >& cpoints, int
numpoints);
};
--- Bezier.h---
---Bezier.cpp---
template <typename T>
array< vector3<T> > *
Bezier<T>::GenerateBezierCurve(const array< vector3<T> >& cpoints,
int numpoints)
{
array< vector3<T> > * points = new array< vector3<T> >(numpoints);
T time = 0.0;
T time_increment = 1.0 / numpoints;
while (time < 0.0)
{
points->add(PointOnCurve(cpoints, time)); //
time += time_increment;
}
return points;
}
---Bezier.cpp---
---main.cpp---
array< vector3<float> > cpoints;
cpoints.push_back(vector3<float>(0.0f, 0.0f, 0.0f));
cpoints.push_back(vector3<float>(1.0f, 0.0f, 0.0f));
cpoints.push_back(vector3<float>(1.0f, 1.0f, 0.0f));
array< vector3<float> > * points =
Bezier<float>::GenerateBezierCurve(cpoints, 100);
---main.cpp---
It all compiles fine, but won't link:
main.cpp:: undefined reference to
`Bezier<float>::GenerateBezierCurve(array<vector3<float> > const&,
int)
Any help would be greatly appreciated!
Thanks,
Joseph Paterson