static variable in the class declaration or definition?

后端 未结 4 1672
夕颜
夕颜 2020-12-01 21:07

I am new to C++.
I have a class like this:

class CodeTest
{
private:
    static const int TOTAL=100;
};

Is TOTAL a dec

4条回答
  •  天命终不由人
    2020-12-01 22:11

    First part of the question:

    This line: static const int TOTAL=100; is a declaration followed by an initialisation.

    TOTAL is an identifier.

    Second part of the question

    const int CodeTest::TOTAL is required to initialize the variable.

提交回复
热议问题