有人可以告诉我下面的课程中有什么问题,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;
}
};