# Include <stdio. h> Class Cdemocls { Public : Int Idata; Public : Cdemocls () {idata = 0 ; Printf ( " % S \ n " ,__ Function __);} ~ Cdemocls () {printf ( " % S \ n " ,__ Function __);}}; Class Cdemocls2 { Public : Static Class Cdemocls CLS; Static Int A; Public : Cdemocls2 () {printf ( " % S \ n " ,__ Function __);} ~ Cdemocls2 () {printf ( " % S \ n " ,__ Function __);}}; Int Main () {cdemocls2 OBJ; // OBJ. Cls. idata = 5; // The following error is reported: /* Testclsstatic. OBJ: Error lnk2019: the external symbol that cannot be parsed "public: static class cdemocls cdemocls2: CLS "(? CLS @ cdemocls2 @ 2vcdemocls @ A), which is referenced in function _ main using testclsstatic.exe: Fatal error lnk1120: 1 external command that cannot be parsed */ Return 0 ;}
Define two classes. The second class wants to use a static Class 1 object. Now the compilation can run and display:
Cdemocls2: cdemocls2cdemocls2 ::~ Cdemocls2
It seems that there is no cdemocls. When the main function is used with variables of the static class, an error is reported directly, and external symbols that cannot be parsed.
Really depressing. I just want the second class not to repeat the first class. Taking the first class as a global variable, I always think it is difficult to manage more global variables.
Alas, I did not expect such a simple requirement.
In addition, static in the class cannot be directly initialized, which is the most annoying. Only initialize once.