Thanks to your replies, I have now figured out a way that should work:
template<typename T, typename P> class CVector3
{
CVector3<T, P> &normalize();
// more stuff
P toPoint() const;
};
typedef CVector3<float, Point3f> Vector3f;
typedef CVector3<double, Point3d> Vector3d;
I'm going to try this and tell you if it worked later. Cheers!
EDIT: Yup, it worked! I had to define toPoint() like this:
template<>
Point3f CVector3<float, Point3f>::toPoint() const
{
Point3f pt = { x, y, z };
return pt;
}
Your answers with traits are certainly a more general solution, but since Point3f is the natural pendant for Vector3f, I like a second template parameter better.