On May 30, 2009, at 3:32 PM, Joe Strout wrote:
William Squires wrote:
A protected property can be accessed via code in IT'S instance, or
in code in a subclass method (which would refer to its inherited
property), but not in other code.
That appears to be a fair description of how RB's compiler
currently works, but there is no reason that it SHOULD work that way.
That is, in the code in Class2, you can refer to Property1 without
an accessor, but you'll be referring to the value of Property1
associated with the instance of Class2 that you created with New.
A different instance of Class2 cannot access the Property1 in the
first instance without an accessor!!
And this isn't even true, since you can trivially access the other
object's Property1 simply by typecasting it to a Class1.
This should be a bug! :) As should:
Public Class MyClass Inherits Object
Protected fMyProp As String
Public Sub Constructor()
fMyProp = "Hi, I'm an instance of MyClass!"
End Sub
End Class
<other code not in MyClass>
Dim a As MyClass
a = New MyClass()
a.fMyProp = "Oopsie, I shouldn't be allowed to do this here!"
Since this code exists outside the scope of MyClass, and fMyProp is
not Public.
Best,
- Joe
--
Joe Strout
Inspiring Applications, Inc.
http://www.InspiringApps.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|