Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Wishlist???
Message
From
03/09/1999 08:23:05
Walter Meester
HoogkarspelNetherlands
 
 
To
03/09/1999 08:00:28
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00260725
Message ID:
00261076
Views:
47
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,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform