I am writingProgramDuring the process, we encountered a strange problem of no initialization.
Finally, we found that a global variable A is written in the CPP where the main function is located. Due to the loading sequence of the header file, a problem occurs when a Class B is used, some data in a is expected to be obtained, but nothing is actually 0, as if a was just initialized.
I don't know what the root cause is. I only know that it must be extern.
In Class B, extern is used to define. However, because the header file of Class B is earlier than the global variable a defined by the main function in CPP, this extern does not seem to work, And vc6 does not prompt errors, as if it is declared directly by default.
The lessons learned are:
Global variables are covered in stdafx. cpp. Pay attention to the loading sequence of header files.