[3533] in java-interest
Re: protected is not?
daemon@ATHENA.MIT.EDU (Edith Au)
Wed Nov 15 18:11:14 1995
To: "D'Arcy Smith" <darcy@arcs.bcit.bc.ca>
Date: Wed, 15 Nov 1995 14:29:13 -0500 (EST)
From: Edith Au <edith@pencom.com>
Cc: java-interest@java.sun.com
In-Reply-To: <30A90EC3.4681@arcs.bcit.bc.ca> from "D'Arcy Smith" at Nov 14, 95 01:48:51 pm
Hi,
> Edith Au wrote:
> >
> > protected variables can be accessed by the methods of its class and subclasses
> >
There is something missing from this statement. Ken Arnold gave a better
explanation for protected variable (but I lost that mail so I can't include
his statement here). Protected variables (and methods) are "friendly" to the
classes in its package. So, protected variables (and methods) can be accessed
by classes from the same package. Also, the default for variables and methods,
and even classes is protected. Sorry for the confusion.
>
> Following your logic what is the value of protected then?
I am not sure if there is a package concept in C++. But one of the
advantages of using protected is preventing people from stealing your
"classes".
Let's say you wrote an application with 5 classes and all of your
variables, methods, classes are protected so classes are "friendly"
within the package. Now, let's say I want to reuse one of your classes
in my class, say class A. The only way class A can use your classes is
by packaging Class A in your package. Which means I have to create a
package directory structure just like the way you do. If your package
name is CompanyX.DeptY, it might not be a good idea for me to do that.....
Anybody has a better idea on the value of protected in Java?
>
> I would interpret the above quote to mean that I can only access protected
> members from within the (sub)class - like protected in C++.
I just got your mail so you know protected in Java and in C++ is not the
same.
I am not sure if Java needs an extra access identifier to implement
protect in C++. I can't think of any reason why it is needed...
Cheers,
Edith
==============================================================================
Edith Au Tel: (212) 513 7777
WWW Specialist Email: edith@pencom.com
Pencom Systems Incorporated WWW: http://www.pencomsi.com/~edith
40 Fulton Street,
NY, NY 10038
===============================================================================
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com