guides:programstyle:globals
This is an old revision of the document!
Global Variables
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; int main() { ... }
You should not use global variables unless you are given permission to do so by your instructor.
guides/programstyle/globals.1596550801.txt.gz · Last modified: 2024/07/25 15:01 (external edit)