1/*
2 Copyright(C) 1998
3 All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4
5 Permission to use, copy, modify, and distribute this
6 software and its documentation for EDUCATIONAL purposes
7 and without fee is hereby granted provided that this
8 copyright notice appears in all copies.
9
10 date : January 1, 1998.
11 authorĀ : Salih Yurttas.
12
13 m_01.cpp
14*/
15
16
17// the following is the worst programming you can do!
18
19// the rule: minimize or eliminate the globals
20// use locals
21
22
23#include <iostream>
24
25using namespace std;
26
27int i=0; // by default, i, j, and a are all global with initializers
28int j=0;
29
30int a=1; // i, j, and a exists and visible in the file scope
31 // i, j, and a are r/w (lhs/rhs) in every function following
32 // declarations/definitions.
33
34void f() {
35 cout << "f / ";
36 cout << ++j;
37 cout << endl;
38 cout << "a = ";
39 cout << ++a;
40 cout << endl;
41}
42
43int main(int argc, char* argv[]) {
44
45 cout << "m / ";
46 cout << ++i;
47 cout << endl;
48 cout << "a = ";
49 cout << ++a;
50 cout << endl;
51
52 cout << endl;
53
54 f();
55
56 cout << endl;
57
58 cout << "m / ";
59 cout << ++i;
60 cout << endl;
61 cout << "a = ";
62 cout << ++a;
63 cout << endl;
64
65 cout << endl;
66
67 f();
68
69 cout << endl;
70
71 cout << "m / ";
72 cout << ++i;
73 cout << endl;
74 cout << "a = ";
75 cout << ++a;
76 cout << endl;
77
78}