tutorial

Page 138

Properties Classes were proposed in object oriented programming paradigm for one of the reasons of having data security. As we know, the members of a structure in C happen to be public and can be accessed freely outside the structure. As a result, there is not any check as to what data is been inserted into the structure members. Hence, in classes we have the “private� specifier by which we can avoid the direct access of the data members of the class. Then we lose the user friendliness of accessing a variable rather than calling a function. Properties happen to be a fantastic blend of both the things. A property constitutes of a private level member to store the data and accessor and mutator methods to interact with the variable. Now what is new in that? The beauty is that the property would be accessed by the user as a local variable but internally the compiler will convert the access statements into appropriate function calls. So the


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.