Sometimes, it is desirable to hide the implementation details of a class to prevent access to proprietary information (including private data) and proprietary program login in a class. Providing clients of your class with a proxy class that knows only the public interface to your class enables the clients to use your class's services without giving the client access to your class's implementation details.
- Proxy class
- Hide implementation details of another class
- Knows only public interface of class being hidden
- Enables clients to use class's services without giving access to class's implementation
- Forward class declaration
- Used when class definition only uses pointer to another class
- Prevents need for including header file
- Declares class before referencing
- Format: class ClassToLoad;
Implementation of a proxy class is demonstrated in Figs. 2.29-2.31.
Figure 2.29:
Implementation class definition.
|
Figure 2.30:
Interface class definition.
|
Figure 2.31:
Interface class member-function definitions and Implementing a proxy class.
|
2004-07-29