Read this article in your language IT | EN | DE | ES
Shared Class:-
ü A shared class consists of a pointer to a shared data block that contains a reference count and the data.
ü When a shared object is created, it sets the reference count to 1. The reference count is incremented whenever a new object references the shared data, and decremented when the object dereferences the shared data. The shared data is deleted when the reference count becomes zero.
ü When dealing with shared objects, there are two ways of copying an object.
· Deep Copy:-A deep copy implies duplicating an object. Making a deep copy can be expensive in terms of memory and CPU.
· Shallow Copy: - A shallow copy is a reference copy, i.e. just a pointer to a shared data block. Making a shallow copy is very fast, because it only involves setting a pointer and incrementing the reference count.
Shared Variables:-
ü Shared variables use the same memory block to store the value of a variable throughout the main report and all of its sub reports. Thus shared variables are even more general than global variables. To use a shared variable, declare it in a formula in the main report as in the following example:
Shared x as Number
x = 1000
And declare it in a formula in the sub report as in the following example:
Shared x as Number
ü To use shared variables, the variable must be declared and assigned a value before it can be passed between the main report and the sub report.