小编ina*_*101的帖子

带有静态变量和函数的C++类中的问题

有人可以告诉我下面的课程中有什么问题,g ++在ubuntu上给出了错误:

class FibonacciGenerator
{
    private:
        static int num1, num2, counting;

    public:

        static void Reset()
        {
            num1 = 0; num2 = 1;
            counting = 1;
        }

        static int GetCount()
        {
            return counting;
        }

        static int GetNext()
        {
            int val = 0;
            if(counting == 1) val = num1;
            else if(counting == 2) val = num2;
            else 
            {
                val = num1 + num2;
                num1 = num2;
                num2 = val;
            }
            counting ++;

            return val;
        }
};

c++ ubuntu static g++ class

1
推荐指数
1
解决办法
771
查看次数

标签 统计

c++ ×1

class ×1

g++ ×1

static ×1

ubuntu ×1