#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
class P
{
public :
static int a;
};
//类内声明,类外定义
int P::a = 1;
void test01()
{
P p;
//通过对象访问
cout << "a = " << p.a << endl;
//通过类名访问
cout << "a = " << P::a << endl;
P p2;
p2.a++;
//所有P的对象公用一个a
cout << "a = " << P::a << endl;
}
int main()
{
test01();
return 0;
}