Walter Meester
HoogkarspelPays-Bas
Silvain,
>I admit that I don't see many uses for a static variable, but they can be usefull and respect a good OO design (IMHO). An example from the top of my head: let say that you have a class that cannot be instanciated more than once. Without a static variable, you need to create a public variable or something like that. Not very OOP. With a static variable, you could create it in the class, initialize it at .T. in the Init() and put it at .F. in the Release(). That way, the class encapsulate this behaviour and respect good OO design.
You mean that you'll have counter in the class to prevent multiple instances ?
If so, I don't think this will work, If you create another instance of a class this class creates it's own static variable with it's own (thus different from the otherone) scope.
Since a static variable can only exist in the code where it was created (or in succesive called procs or methods, if the scope is private) you'll have to create it in the class itself.
Maybe someone has a better example where static variable can be of use...
Walter,
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement