Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Wishlist???
Message
De
03/09/1999 08:23:05
Walter Meester
HoogkarspelPays-Bas
 
 
À
03/09/1999 08:00:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00260725
Message ID:
00261076
Vues:
45
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
Fil
Voir

Click here to load this message in the networking platform