I don’t understand the difference between protected and private members or methods, as I assumed both will hide the member or the function to access from outside the class.
What is the difference between the protected and the private keywords?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
private– only available to be accessed within the class that defines them.protected– accessible in the class that defines them and in other classes which inherit from that class.