Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

C++: private Vs Protected

  • 16-05-2003 9:08pm
    #1
    Moderators, Arts Moderators, Recreation & Hobbies Moderators, Sports Moderators Posts: 9,586 Mod ✭✭✭✭


    What is the difference between private and protected in C++ classes?

    It seems that they do the same thing. i.e. protect outside functions from using whatever is private / protected.


Comments

  • Registered Users, Registered Users 2 Posts: 1,931 ✭✭✭Zab


    Protected will allow access from subclasses that publicly extend the class. Private won't.

    Zab.


  • Registered Users, Registered Users 2 Posts: 14,149 ✭✭✭✭Lemming


    Think of it like this:

    A person's appearance is Public
    A person's internal workings (eg. heart, lungs) are Protected as they are common to all people and passed on.
    A person's memories/opinions/skills are Private and unique to that person.


  • Moderators, Arts Moderators, Recreation & Hobbies Moderators, Sports Moderators Posts: 9,586 Mod ✭✭✭✭BossArky


    Nice one lads, cheers :)


Advertisement