Jump to content

How To Avoid Using Globals


mike177

Recommended Posts

Using OOP eliminates the need for many globals which can be made "per object instance".

 

An alternative to a registry class is to have a single global array storing all your globals.  Then you just have to worry about not clobbering that single array.  If you're keen about not polluting the namespace, you can make the "global" variable array static inside a function (but then the function itself is in the global namespace, so you haven't gained much).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.