PureBasic and the Object-Oriented Programming Appendix
The paragraphs which follow deal with considerations on our Object-oriented approach to improve the program runtime the performances of . Optimisation:
Get() and Set() methods: Both consist in coupling a pointer to the object, the second solution brings a layer to the first one. First solution:
To act on var2 attribute write:
It is then possible both to examine and to modify it. Second solution:
Creating an object from Class Rectangle1, means declaring the object
thanks to this new Structure.
with,
To access to the Draw() method, write:
To access to the var2 attribute, write:
This second solution has the advantage to have only a single element
that can be deal as an object from which all the attributes are accessible
from outside of the class. The inconvenience concerns essentially the fact that it is necessary to maintain a new structure within the Class.
|
Dräc - 2005 |