[LC++]declaring and using manipulating global variables

Julien Patrick Claassen julien at c-lab.de
Fri May 16 10:15:02 UTC 2003

  My unhappiness. I want to use a global variable for counting up an
array-index. But now all functions that deal with my array have to get it as
a parameter. That makes me unhappy, because most of them, don't even do
something with it directly (they may just pass it along for another
"subfunction" they call. Besides, I thought there was a way to declare a
global variable, that is known everywhere and can be changed everwhere. Being
changed meaning, changing it globally. I simply tried it with something like:

#include <something>
int glob_index;
(functions here using glob_index);
int main()
  glob_index = 6;
  change_glob_index(); // being a function that manipulates glob_index
  return 0;

  I used some simple output to see the value of glob_index and saw, that it is
only changed locally.
  Is there a - let's say - more elegant way of doing this? Or is my way the
  Kindest regards

Julien Patrick Claassen
jclaassen at gmx.de
julien at c-lab.de

Fuerstenallee 11
33102 Paderborn

Phone: (+49) 5251 60 6060
Fax: (+49) 5251 60 6065


More information about the tuxCPProgramming mailing list