Quote:Original post by swinchen
I don't think there will ever be a time. It was more of an academic problem. I was looking through Data Structures for Game Programmers and saw how the author(s) were using this technique. They failed to mention that it doesnt work with floats or doubles :/
In that case, consider working with a single template parameter, and letting 'zero' be either a default-constructed T, or a T constructed with an argument of 0 (as a literal) - the latter will work for all numeric types plus everything that declares a constructor with that signature (one parameter of a type compatible with int).
template <class T>class CVector3{ private: T m_x, m_y, m_z; public: CVector3() : m_x(T(0)), m_y(T(0)), m_z(T(0)) {} // or just T() instead of T(0) CVector3(T x, T y, T z) : m_x(x), m_y(y), m_z(z) {} };// Or more simply:CVector3(T x = T(0), T y = T(0), T z = T(0)) : m_x(x), m_y(y), m_z(z) {}// provides both ctors, and two more probably-undesired ones