What is protected access?
What are some of the relative merits of using protected access vs. private access in base classes?
Protected vs. Private Access
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Jignesh TrivediRank #16 · 50.3K reputationPosted Aug 21, 2013, 6:55 PM EDT
hi,
protected is only used/accessed by class and any sub class (derived class). whereas private can only access by class it seft.
Please refer
http://msdn.microsoft.com/en-us/library/ms173121.aspx
hope this will help you.
Steph Bassos15 reputationPosted Aug 21, 2013, 7:04 PM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Aug 21, 2013, 7:15 PM EDT
hi,
As explain above protected is also access by own class as well as its friend class(means derived class or sub class) so it you have requirement like member is only access by itseft and its friend class than you must define this member as a protected.
when you want to hide member from the outer world then you must define this meber as private.
hope this will help you.