[Next] [Prev] [Up] [Top]

7.0 Classes

Encapsulate singleton classes within a static method (R)


Classes which have only one instance (ie, window manager), should store the instance pointer inside the class as a static method. There should also be a static method for constructing the instance (if arguments are required) and a standard static access method. This follows the Singleton design pattern.

The static access method should be named according to the class. For example,

TWindowMgr :: fInstance = NULL; // private/protected pointer

TWindowMgr :: newWindowMgr (...); // optional construction

TWindowMgr :: theWindowMgr(); // access method

TWindowMgr :: destroyWindowMgr(); // optional destruction


No Title
[Next] [Prev] [Up] [Top]

Generated with CERN WebMaker

This site was grabbed using the TRIAL version of Grab-a-Site. This message does not appear on a licensed copy of Grab-a-Site.