Attributes are used to store data. There are two types of attributes-
Instance Attributes:
It is declared in local class using the DATA keyword.
Instance attributes only access by using objects of the class.
Instance Attributes Example:
CLASS cl_main DEFINITION.
PUBLIC SECTION.
DATA: a TYPE i.
ENDCLASS.
DATA: ob TYPE REF TO cl_main.
CREATE OBJECT ob.
ob->a = 10.
WRITE:/ ob->a.
Static Attributes:
It is declared in local class using CLASS-DATA keyword.
Instance attributes can be accessed by using objects of the class or by class name also.
Static Attributes Example:
CLASS cl_main DEFINITION.
PUBLIC SECTION.
CLASS-DATA: b TYPE i.
ENDCLASS.
DATA: ob TYPE REF TO cl_main.
CREATE OBJECT ob.
cl_main=>b = 20.
WRITE: ob->b.
If you have any Question you can contact us or mail us. We will reply you as soon as possible.
Post a Comment