New Message on trivandrumusergroup

Friend v/s protected friend

Reply
  Reply to Sender   Recommend Message 2 in Discussion
From: Prashi

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

    New Message on trivandrumusergroup

    Friend v/s protected friend

    Reply
      Reply to Sender   Recommend Message 1 in Discussion
    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.


    View other groups in this category.


    Also on MSN:
    Start Chatting | Listen to Music | House & Home | Try Online Dating | Daily Horoscopes

    To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.

    Need help? If you've forgotten your password, please go to Passport Member Services.
    For other questions or feedback, go to our Contact Us page.

    If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
    Remove my e-mail address from trivandrumusergroup.

    Reply via email to