Why is it bad to put stuff in global scope

Hi there I was just wondering why is it bad to declare variables in global scope like it can make code shorter for ex

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Int a = 0, b = 0;

int add()
{
   Cout ......;
   cin >> a >> b;
   Cout .... a + b;
}

int subtract()
{
   Cout ......;
   cin >> a >> b;
   Cout .... a - b;
}

int devide()
{
   ........
}
int multiply()
{
   ........
}

Int main ()
{
   char choice = 'a'
   Cout .....;
   Cin >> choice;

   If ....
   If ....
   If ....
   If ....
}


Sorry for code, I wrote it on ipad so I couldn't write all. So that saved me a few lines. Why is it bad? And leave the capitals out.
Last edited on
The article also left out the disaster relating to external dependencies that hurt modularity (making unit testing more difficult, for example).
Thanks I'm nearly finished reading it.thanks guys, I got it.
Topic archived. No new replies allowed.