3.7 Scope and Accessibility in Class Modules The

3.7 Scope and Accessibility in Class Modules The notion of scope in class modules is more involved than it is in standard modules. As far as local variables (block-level and procedure-level) are concerned, there is no difference we have block scope and procedure-level scope. However, variables declared in the Declarations section of a class module can be assigned one of the following access modifiers: Public Private Friend Protected ProtectedFriend (For standard modules, only Public, Private, and Friend are allowed.) Note that class modules themselves can be declared with any one of the three access modifiers: Public, Private, or Friend (Protected is not allowed). When a class module declaration specifies one of these access modifiers, this simply restricts all of its members to that level of access, unless a member’s access is further restricted by the access modifier on the member declaration itself. For instance, if the class has Friend access, no member can have Public access. (Put another way, the Public access is overridden by the Friend class access.) On the other hand, all four access modifiers apply to members of the class module?that is, to variable, constant, enum, and procedure declarations within the class module. The complications come because there are actually three types of access to a class member, and these generally have different scopes. To clarify, let’s make the following definitions, which are not standard but descriptive. For example, consider a variable declaration in the Declaration section of a class module named Class1: AccessModifier classvariable As Integer This variable can be accessed in the following ways: Direct access Refers to accessing the member without any qualification, as in: classvariable = 100 When attempting to access a variable using direct access (that is, without qualification), the variable’s scope takes one of three forms: The declaring class only The declaring class and its derived classes within the declaring project only The declaring class and its derived classes, in any project that holds a reference to the declaring project Class/object access Refers to accessing the member through qualification, either with the class name or the name of an object of that class.
Note: If you are looking for good and high quality web space to host and run your java application check Vision java hosting services

Comments are closed.