Tutorial :What is Global data (Has the term become stretched)?


What exactly is global data?

This may seem like a very rudimentary question but the reason I'm asking is because I'm wondering has the term become stretched over time - i.e it dosn't just apply to data in the "Global" namespace (in c++) or a variable that is available in every scope.

So, what do you consider to be global data?


I agree David, global can quite often mean different things to different people in different languages!

Personally I hate globals which are truly global, i.e. available to everything, everywhere. The greater the restriction of a scopes' variable, generally the better.

The scope of the information often has to be open to lots of functions within a module, this is OK, but should be limited where required. These I would define a module globals or local globals.

Variables which are shared between modules through a defined interface and only included as required are OK-ish, but data passed back and forth (or pointers to data) from/to functions are the best.

Of course, this is all my personal opinion in my native language (C) and might not agree with everyone's opinion!


Global data is a variable that can be put in any local scope (i.e. of a function) without passing it as a parameter or class attribute.

In some languages you need a global or extern keyword to import it, in others it enters the function's scope automatically.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »