|
| Declaring the class and its elements |
| Iniciado por guest, 12,feb. 2018 13:56 - 2 respuestas |
| |
| | | |
|
| |
| Publicado el 12,febrero 2018 - 13:56 |
I am trying to understand Class in Windev.
I guess I understand the Meaning of PUBLIC, PROTECTED and PRIVATE.
But didn't know When to put or not to put GLOBAL in front of them .
For Example What would be the difference between these Two ?
GLOBAL PRIVATE
PRIVATE ___________________________________ or these two??
PRIVATE CONSTANT
GLOBAL PRIVATE CONSTANT |
| |
| |
| | | |
|
| | |
| |
| Publicado el 12,febrero 2018 - 14:21 |
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
Best regards |
| |
| |
| | | |
|
| | |
| |
| Publicado el 14,febrero 2018 - 04:04 |
Thanks Fabrice ! So There is nothing like GLOBAL PRIVATE or Like GLOBAL PUBLIC When declaring Class ??
Thanks Again ?? |
| |
| |
| | | |
|
| | | | |
| | |
|