?????????????????c++???е???????????????????????????????????static??????????????????????????????????????????????????????????????????????????
????(1)???????
????????????????????????????????????????????????????????(???????????????????????У???????????)????????????????????????????????????????á?????????????????????????????????????????????????????????????????????????
???????????????????????????ж?????????
????StaticClassName    MainClassName:: staticMemberName =value;
???????????????
#include <iostream>
using namespace std;
class   MyClass
{
public:
MyClass(){ this->non_static_member=10;}
static  int  static_member;
int          non_static_member;
};
int MyClass::static_member=5;
int main()
{
MyClass  first??second;
//???????MyClass??????????????????????????????????????
cout<<&(first.static_member)<<" "<<&(second.static_member)<<endl;
//???????MyClass???????????????????????????????????????
cout<<&(first.non_static_member)<<" "<<&(second.non_static_member)<<endl;
system("pause");
}
????(2)???????
????C++?????е???????(???/????)?????????????????ж??????????????????????????????????????????ó???????????????
??????1?????????????????????????????????????????????????????????????????????
????1??class:: staticMethod()
????2) classObject.staticMethod()
???????????????????????????????????????????????this?????????????????????????????????this???????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????棬??????????????????????????????????????????????????????????????
#include <iostream>
using namespace std;
class   MyClass
{
public:
MyClass(){ this->non_static_member=10;}
static void  display();
static  int  static_member;
int          non_static_member;
};
int MyClass::static_member=5;
void MyClass::display()
{
cout<<static_member<<endl;
cout<<non_static_member<<endl; //error C2597: illegal reference to non-static member 'MyClass::non_static_member'
}
int main()
{
system("pause");
}