重点:
1.长时间不使用static会忘记,记录一下,static变量的设置使用。
class Test
{
public:
Test() = default;
~Test() = default;
public:
int GetNum() { return m_num; };
void SetNum(int num) { m_num = num; };
private:
static int m_num;
};
int Test::m_num = 10;
int main()
{
Test t;
std::cout << t.GetNum() << std::endl;
t.SetNum(20);
Test m;
std::cout << m.GetNum() << std::endl;
return 0;
}