Application Development and Automation 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: 
Read only

Object Oriented

Former Member
0 Likes
347

Could anybody explain me regarding the public, private, protected visibilities.

2 REPLIES 2
Read only

Former Member
0 Likes
322

Hi

seer the diff

Access--


-
public protected ---private

members of the same class--- yes -yes--


yes

members of derived classes -yes- yes----


no

not members--


yes- no -


no

please reward points for helpful ans's

kiran.M

Message was edited by:

Kiran Machavarapu

Read only

Former Member
0 Likes
322

Hi Tazeen,

Welcome to SDN....

<b>Public attributes</b>

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.

<b>Private attributes</b>

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,

<b>Protected components</b>

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.

Thanks,

Vinay