且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么是非顺序整数c ++枚举的***方式

更新时间:2022-11-22 17:38:50

由于Visual C ++ 2010编译工具包(不完全符合C ++ 11)的限制,我不得不将自己投降到较差的方法。

Due to the limitations of Visual C++ 2010 Compilation Toolkit (not fully C++11 compliant), I had to surrender myself to inferior approaches.

https://***.com/a/15961043/ 383779 还建议我一个有趣的方法来获取价值。

The post at https://***.com/a/15961043/383779 also suggested me an interesting approach for getting the values.

class Rotations
{
public:
    typedef enum
    {
        ZERO= 0,
        PLUS180= 180,
        PLUS90 = 90,
        MINUS90 = -90
    }PossibleValues;

    static const PossibleValues PossibleValuesCollection(int index) {
        static const PossibleValues values[] = { ZERO, PLUS180, PLUS90, MINUS90 };

        return values[index];
    }

    static int Count() { return 4; }
    static PossibleValues Default(){ return ZERO; }
};