Autor: Fabrice Harari
Link zum Beitrag: [
27130.foren.mysnip.de]
Hi
GLOBAL means that you have only ONE instance of that 'thing' in memory,
and it's there all the time, EVEN if you DON'T instantiate an object of
the class...
By example, if you do
Global
iNumberOfObjects is int
You just created a counter in which you can know the number of objects
of that class instantiated at any given time.. Just do
iNumberOfObject++ in the constructor
and iNumberOfObjects-- in the desctructor of your class,
then, from anywhere in your program (even the first line of code of the
project), you can do:
info(NameofCLASS::iNumberOfObjects)
the difference in USING global variable or methods is that you don't do
: NameOfObject:iNumberOFObject, but NAMEOFCLASS::iNUmberOfObject (as
this exist OUTSIDE of the instantiation of any object)
This is great to use as internal maintenance tools (keep an array of
existing objects to debug any memory leak, garbage disposal, etc)
Everything else (private/publoc,etc...) is INSIDE an instantiated
object.
Very powerful stuff
Best regards