Global variables are variables that are declared outside the scope of a function. While it is common, even encouraged, to declare global constants, global variables are problematic as program size increases. Because of this, the use of global variables should be limited.
#include <iostream> using namespace std; // count is a global variable. This should be avoided. int count; // MAX_SIZE is a global constant. This is not a problem. const int MAX_SIZE {10}; int main() { ... }
You should not use global variables unless you are given permission to do so by your instructor.