02-14-2007 9:19 AM
Hi experts,
If I may ask what is the difference between static & instance of a class?
Example.
PRIVATE SECTION.
DATA: name TYPE string,
planetype TYPE saplane-planetype.
CLASS-DATA: n_o_airplanes TYPE i.
02-14-2007 9:27 AM
Hi,
INSTANCE variables:
Things that an object knows about itself are called instance variables.
They represent an objects state( the data ), and can have unique values for each object of that type.
STATIC variables:
When a member is declared static, it can be accessed before any objects of is class are created, and without reference to any object. You can declare both methods and variables static.
STATIC means they are common to all Instances of the Class, where as INSTANCE variables are pertains to a Particular object of that class.
All the Instances of the class share the STATIC varaibles but in case of INSTANCE variables each object have its own copy.
Regards,
Anji
02-14-2007 9:28 AM
Hi marc,
1. normally instance concept is used.
2. It means, that,
the program has to create the object (of the type of that class),
and only after creating that object in memory,
it can access that paritcular attribute.
3. Otherwise,
4. If it is static,
then simply by using the classname (without creating the object in memory),
we can use the attribute.
regards,
amit m.