All the Perl that's Practical to Extract and Report

Navigation

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Without JavaScript enabled, you might want to
use the classic discussion system instead. If you login, you can remember this preference.

Please Log In to Continue

I'm not much of a Stackoverflow user. However it doesn't strike me as a place designed to handle opinion-based questions. chaos' suggested rewrite:

what reasons are there to use protected members and/or to avoid them?

seems a little better, but I think the question still needs to be more detailed. Perhaps something along the lines of:

I have a class (X) and its child class (X::Y). X has a variable Z for some purpose. It doesn't make sense (for some reason) to make Z an attribute of X::Y but X::Y still needs to be able to access Z. I could implement it as a protected member, or I could expose it some other way. What is the correct approach in this situation and why?

I think the problem with your original question is that it is scope-less. Protected variables have some advantages and some disadvantages. However it's difficult to answer with something that would be relevant to the question because it's too hard to guess what you were thinking when you wrote it.