Hi,
According to VS.Net
dpcumentation
Entities declared with the Protected modifier have
Protected access. Protected access can only be specified on
members of classes (both regular type members and nested classes). A
Protected member is accessible to a derived class, provided that either
the member is not an instance member, or the access takes place through an
instance of the derived class. Protected access is not a superset of
Friend access. - You can access a protected method
only from a child class method
Entities declared with the Friend modifier have Friend
access. An entity with Friend access is accessible only within the
program that contains the entity declaration. -- You can access the
friend method from any class in your application
Entities declared with the Protected Friend modifiers have the
union of Protected and Friend access.
Class Base
Protected Sub MyProtected()
Console.WriteLine("Base -- Protecetd")
End Sub
End Class
Public Class Child
Inherits Base
Public Sub ChildMethod()
Call MyProtected()
End Sub
End Class
Sub Main()
Dim objChild
As New Child()
Dim objBase
As New Base()
'objBase.MyProtected() ' - this stmt wont
compile cuz MyProtected() is protected and hence
'can be acessed only thru member methods of
a Child Class
objChild.ChildMethod()
Console.ReadLine()
End Sub
In the above code snippet if u change the access
modifier from Protected to Protected Friend u'll be able to access it, cuz its
both friend as well as protected.
I think access specifiers and access modifiers mean
the same. Any thoughts on this anyone??
As to ur final question-- All the modifiers cannot
be used with classes. Specifically the protected modifier can be used only with
inner classes.
YOu can use all the access modifiers with
methods and fields.
Thanks,
Prasanth
----- Original Message -----
Sent: Wednesday, June 30, 2004 5:45
PM
Subject: Friend v/s protected
friend
Friend
v/s protected friend
Reply
|
|
| From: Anjali_Mehta_DotNet |
Could some one with example tell me
about Freind and Protected Friend, please
Also Access Specifer v/s Access
Modifier.
Can all these Modifiers and
Specifier can be used to declare variables,classes,functions ?
| | View other groups in this
category.
|