我想做一个角度类,以弧度或度数进行初始化,但我不知道这是否是个好主意。我正在考虑这样的事情:
class Radian;
class Degree;
/**
  * My angle class.
  **/
class Angle
{
    private:
        float m_radian;
    public:
        explicit Angle(const Radian& rad);
        explicit Angle(const Degree& deg);
        float GetRadian(void) const
        {
            return this->m_radian;
        }
        float GetDegree(void) const
        {
            return ToDegree(this->m_radian);
        }
        bool IsEqual(const Angle& angle, float epsilon = 0.001f) const
        {
            return Abs<float>(this->m_radian - angle.m_radian) < epsilon;
        }
        void Set(const Angle& ang);
    protected:
        Angle(void) : m_radian(0.0f)
        {}
        Angle(float rad) : m_radian(rad)
        {}
};
class Radian : public Angle
{
    public:
        Radian(void)
        {}
        Radian(float r) : Angle(r)
        {}
};
class Degree : public Angle
{
    public:
        Degree(void)
        {}
        Degree(float d) : Angle(ToRadian(d))
        {}
};
/// Trigonometric functions.
float Sin(const Angle& angle);
...
这样我就不会在我的代码中混淆弧度和度数。但是,这是一个好主意还是我应该使用其他设计?
