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

C++: private Vs Protected

Options
  • 16-05-2003 10:08pm
    #1
    Moderators, Arts Moderators, Recreation & Hobbies Moderators, Sports Moderators Posts: 9,514 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 Posts: 1,931 ✭✭✭Zab


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

    Zab.


  • Registered Users Posts: 14,148 ✭✭✭✭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,514 Mod ✭✭✭✭BossArky


    Nice one lads, cheers :)


Advertisement