Hi,
I've just learned that Java's 'protected' access specifier has a different effect than that in C++. So is there a way to make a member of a base class visible to its inheritors but not globally?

Dean

Recommended Answers

I've just learned that Java's 'protected' access specifier has a different effect than that in C++. So is there a way to make a member of a base class visible to its inheritors but not globally?

Assuming by globally you mean "other classes in the same package", then no, there …

Jump to Post

All 4 Replies

Thats exactly what protected means.

I've just learned that Java's 'protected' access specifier has a different effect than that in C++. So is there a way to make a member of a base class visible to its inheritors but not globally?

Assuming by globally you mean "other classes in the same package", then no, there is no way to get around this behaviour. Is there any specific problem arising from this that you are trying to solve?

Hmm come to think of it no there are no problems because of this issue, I just thought my assignment would be neater if I could avoid making private functions which I only need to use in sub-classes public.

Anyways thanks for the replies guys, much appreciated :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.