Shared methods
You
can have as many shared (static, in C#) methods as you want. But the
constraint here is that these methods will not be available from the
class's instance objects. Also, with shared methods the benefits of
object "construction" are not available, since shared methods can only
be called on the class directly rather than on the instances. Also,
shared methods do not have access to the class's non-shared or
non-static member variables.
Protected
members are different from friend members...Consider any class "A".
Friend methods are those that belong to a different class but have
access to A's members. Protected members are those members that can be
accessed by a derived class's methods - this is different from private
members which can only be accessed by the methods of A.Consider the class "A" mentioned above:
Member type Access level Private Can be accessed only by methods of A Protected Can be accessed by methods of A as well as methods of any class derived from A
For
friend members, first of all, only "Methods" or "Functions" can act as
"Friends" of a class and a method belonging class B must be declared as
a friend method in class A so that B.FriendMethod() can access member
variables of class A.
Thursday, July 22, 2004
Shared & Protected methods
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment