Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

visibility sections

Former Member
0 Kudos

what are public,private,protected components and their purpose

3 REPLIES 3

matt
Active Contributor
0 Kudos

A public component is available outside of the class. A private component is available only inside the class. A protected component is available only inside the class and any subclasses (or friends of the class).

The purpose of the three visibilities is to encapsulate - i.e. only expose to external manipulation what needs to be exposed, and hide everything else - and to allow for inheritance.

How you actually use them depends on the application.

matt

Former Member
0 Kudos

hi,

Public attributes

Public attributes are defined in the PUBLIC section and can be viewed and changed from outside the class. There is direct access to public attributes. As a general rule, as few public attributes should be defined as possible.

PUBLIC SECTION.

DATA: Counter type i.

Private attributes

Private attributes are defined in the PRIVATE section. The can only be viewes and changed from within the class. There is no direct access from outside the class.

PRIVATE SECTION.

DATA: name(25) TYPE c,

planetype LIKE saplane-planetyp,

Protected components

When we are talking subclassing and enheritance there is one more component than Public and Private, the Protected component. Protected components can be used by the superclass and all of the subclasses. Note that Subclasses cannot access Private components.

<<< REMOVED BY MODERATOR >>>

Please see the [Forum Rules of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement] for more informations.

Edited by: Marcelo Ramos on Nov 28, 2008 2:40 PM

Former Member
0 Kudos

This message was moderated.