11-27-2007 5:35 AM
hi,
what is different between Public Section and Private Section and Protected Section?
Reply me soon........
Regards,
Suresh.
11-27-2007 5:40 AM
Component visibility
This is one of the most important concepts of OOP, here we provided with the flexibility to
assign visibility of the class components. But before we proceed any further lets clear the
fact what do we mean by visibility of class components?
The components of a class can only be accessed through the objects but declaring the class
components in different domains, which are defined as Public Private and Protected, these
domains control the accessibility.
Public components of a class can be accessed by the objects of a class components in the
public domain are totally visible outside the class other components within the class can also
access them.
Private components cannot be accessed by the objects of the class they can only be accessed
by the members within the class i.e. any member function within the class can access the
private members thus from the point of visibility no private components are visible outside
class. The sequence of declaring the components are public protected and private.
Example
CLASS my_class DEFINITION.
PUBLIC SECTION.
METHODS: test_method.
PROTECTED SECTION.
PRIVATE SECTION.
DATA: name TYPE C.
ENDCLASS.
CLASS my_class IMPLEMENTATION.
METHOD test_method.
Write:/ this is my test method.
ENDMETHOD.
ENDCLASS.
11-27-2007 5:39 AM
Hi,
we can access data of Public section any where in program.
we can access data of private section only in that class in which it defined
and we can access data of protected section in that class in which it defined and
in derived class.
Regards,
Prashant
11-27-2007 5:39 AM
HI
<b>Public Section</b>
All of the components declared in the public section are accessible to all users of the class, and to the methods of the class and any classes that inherit from it. The public components of the class form the interface between the class and its users.
<b>Protected Section</b>
All of the components declared in the protected section are accessible to all methods of the class and of classes that inherit from it. Protected components form a special interface between a class and its subclasses. Since inheritance is not active in Release 4.5B, the protected section currently has the same effect as the private section.
<b>Private Section</b>
Components that you declare in the private section are only visible in the methods of the same class. The private components are not part of the external interface of the class.
<b>Rewar di fusefull</b>
11-27-2007 5:40 AM
Component visibility
This is one of the most important concepts of OOP, here we provided with the flexibility to
assign visibility of the class components. But before we proceed any further lets clear the
fact what do we mean by visibility of class components?
The components of a class can only be accessed through the objects but declaring the class
components in different domains, which are defined as Public Private and Protected, these
domains control the accessibility.
Public components of a class can be accessed by the objects of a class components in the
public domain are totally visible outside the class other components within the class can also
access them.
Private components cannot be accessed by the objects of the class they can only be accessed
by the members within the class i.e. any member function within the class can access the
private members thus from the point of visibility no private components are visible outside
class. The sequence of declaring the components are public protected and private.
Example
CLASS my_class DEFINITION.
PUBLIC SECTION.
METHODS: test_method.
PROTECTED SECTION.
PRIVATE SECTION.
DATA: name TYPE C.
ENDCLASS.
CLASS my_class IMPLEMENTATION.
METHOD test_method.
Write:/ this is my test method.
ENDMETHOD.
ENDCLASS.
11-27-2007 5:42 AM
Hi,
Refer this link:
<u>http://help.sap.com/saphelp_nw70/helpdata/en/41/7af4eca79e11d1950f0000e82de14a/content.htm</u>
Thanks
Vasudha
11-27-2007 5:45 AM
Public Section
All of the components declared in the public section are accessible to all users of the class, and to the methods of the class and any classes that inherit from it. The public components of the class form the interface between the class and its users.
Protected Section
All of the components declared in the protected section are accessible to all methods of the class and of classes that inherit from it.
Private Section
Components that you declare in the private section are only visible in the methods of the same class.