Professional Documents
Culture Documents
Can Global Variables Be Dangerous
Can Global Variables Be Dangerous
In above code, we notice one of the biggest problem of global variable that is Debugging. It means if we trying to gure out where that
variable c has changed between thousands of lines of code is very di cult job.
In multihreaded environment a global variable may change more than once (in different execution orders) and cause more problems.
Global variables are generally used for constants. Using them for non-const values is not recommended.