Inheritance - Modifiers property

  • Thread starter Thread starter Chris Adams
  • Start date Start date
C

Chris Adams

Hello,

I just finished an online tutorial regarding Visual
Inheritance. It was very informative, despite the fact
that I am still unclear on two of the settings for the
Modifiers property.

I understand how to use the Private & Public settings, but
became confused on the purpose of the Protected & Friend
settings.

Could anyone please explain why I would use these instead
of Private & Public?

Thanks in Advance,
Chris Adams
 
Private members (properties, methods, and fields) can only be used by the
class that contains them.
Protected members can be used by classes that inherit the class that
contains them. For example, if you create a base form (MyBaseForm), and you
then you create a MySummaryDialog that inherits MyBaseForm, then
MySummaryDialog can see and use the MyBaseForm protected members, but other
classes that don't inherit MyBaseForm cannot.
Friend members can be used by any class as long as the classes are inside
the same project.

-Rob Teixeira [MVP]
 
Rob said:
Private members (properties, methods, and fields) can only be used by
the class that contains them.
Protected members can be used by classes that inherit the class that
contains them. For example, if you create a base form (MyBaseForm),
and you then you create a MySummaryDialog that inherits MyBaseForm,
then MySummaryDialog can see and use the MyBaseForm protected
members, but other classes that don't inherit MyBaseForm cannot.
Friend members can be used by any class as long as the classes are

Also, For non nested classes, Public Members, have the scope the entire
application
provided that the access level is not limited by the Access level of the
class itself
 
In addition, "Protected Friend" members have the access level of "Protected"
members and "Friend" members (They can be accessed by derived classes in any
project and by any other class in the same project)

HTH,

Trev.
 
Back
Top