c++ declare global variable code example
Example 1: c++ global variable
// a.cpp
int x = 5;
// b.cpp
extern int x; // allows b.cpp to access 'x' from a.cpp
Example 2: cpp global variable
int g_x; // global variable g_x
// a.cpp
int x = 5;
// b.cpp
extern int x; // allows b.cpp to access 'x' from a.cpp
int g_x; // global variable g_x