Sunday, June 24, 2018

What are public, private and protected members?

These are different access attributes for class members.

1) Private data members of a class can only be accessed from within the class. These data members will not be visible in derived classes

2) Public members can be accessed from within the class as well as outside the class also. These are also visible in derived classes

3) Protected data members are similar to private members in the sense that they are only accessible within the class. However unlike private members, these are also visible in derived class.

No comments:

Post a Comment