mardi 21 juillet 2015

How C++ differentiates between a call to global variable and declaration of a global variable?

This is the most confusing part for me from section Global Variables and linkage properties.

  extern int g_var1;

Statement would be something like this when declaring an external non-const global variable. I think I will write exactly the same for calling (forward-declare) the variable (g_var1) in some other file. If both the statements are same, how C++ knows whether the variable was declared or was being called?

Aucun commentaire:

Enregistrer un commentaire