I'm trying to write some math code for a project and I stumbled upon a interesting problem:
template<class T> class Radian;
template<class T> class Degree;
template <class T>
class Radian
{
public:
T mRad;
public:
Radian(const Degree& d);
};
template <class T>
class Degree
{
public:
T mDeg;
public:
Degree(const Radian& d);
};
inline Radian::Radian ( const Degree& d )
{
}
inline Degree::Radian ( const Radian& d )
{
}
Note that the code is bigger but I removed unnecessary functions so you can understand it better.
I understand how templates work, I know they are generated at compile time but for this particular example I don't really understand what syntax I should use. I'm aware of the fact that in the constructors Degree should have a template argument but I'm not sure how to write it. From what I see I might have to use another template but it would be nice to use the same T for both since I won't convert from Degree_float to Radian_double.
Could anyone shed some light on this?
Thank you.