In practice, the following problems are encountered:
class CC {#pragma region Methodpublic:static void Method1();private:static void Method2();#pragma endregion Method#pragma region Propertystatic int p1= 3;static int p2;static short p3[...][...];#pragma endregion Property};
After compilation, the error1: p1 variable must be a constant before it can be initialized within the class. Variables are defined and declared. Pair
The static member declarations and definitions of the class must be separated, that is, they must be declared inside the class but not outside the class.
Is absolute, as the error message tells us that when a static member is a constant, the Declaration can be completed within the class.
And definition work.
...static const int p1 = 3;...
Likewise, p2 variables need to be defined outside the class. P3 static array members or pointers must also be defined outside the class.
Type Class: PropertyName here int CC: p2 = 3; short CC: p3 [] [];
Finally, remember that static members are shared within the scope of the class, and they are independent of the class instance.