Defining the Component Writer's Interface

From RAD Studio
Jump to: navigation, search

Go Up to Controlling Access

Declaring part of a class as protected makes that part visible only to the class itself and its descendants (and to other classes that share their unit files).

You can use protected declarations to define a component writer's interface to the class. Application units do not have access to the protected parts, but derived classes do. This means that component writers can change the way a class works without making the details visible to application developers.

Note: A common mistake is trying to access protected methods from an event handler. Event handlers are typically methods of the form, not the component that receives the event. As a result, they do not have access to the component's protected methods (unless the component is declared in the same unit as the form).

See Also