You only want one count
variable, right? Well this line:
int count;
Defines a count
variable for you. If you stick that in multiple files (by including it in a header), then you'll have multiple count
variables, one for each file, and you'll get errors because they'll all have the same name.
All the extern
keyword does is say that there is a count
variable defined in some other file, and we're just letting the compiler know about it so we can use it in this file. So the extern
declaration is what you want to put in your header to be included by your other files. Put the int count;
definition in one source file.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…