I use the following template classes:
template <class T> class Point2D { private: T x; T y; ... }; template <class T> class Point2D; template <class T> class Line{ private: Point2D <T> *start; Point2D <T> *start; .... };
If I want to create a Line object, I need to write a point type and a Line type
int main { Point2DC<double> p1(0,0); Point2DC<double> p2(10,10); Line<double> l(&p1,&p2); ... }
I find it rather pointless ... If the points are double, then the line should also be double ... Is it possible to plan only patterns in the Line class and not templatize all classes, something like this
template <class T> class Point2D; class Line{ private: template <class T> Point2D <T> *start; Point2D <T> *start; .... };
and use
int main { Point2D<double> p1(0,0); Point2D<double> p2(10,10); Line l(&p1,&p2); ... }
source share