Advertisement Remove all ads

Differentiate Between Protected .And Private Me~Bers of a Class. in Context of Object Oriented Programming. Also, Give a Suitable Example Illustrating Accessibility/Non-accessibility of Each Using a Class and an Object in C++. - Computer Science (C++)

Differentiate between protected .and private me~bers of a class. in context of Object Oriented Programming. Also, give a suitable example illustrating accessibility/non-accessibility of each using a class and an object in C++.

Advertisement Remove all ads

Solution

Protected Member: Protected Members are the members that can be used only by member functions and friends of the class in which it is declared. The protected members are similar to private members that they cannot be accessed by non-member functions.Protected members are inheritable but private members are non-inheritable.

Private Members: Private Members are the class members that are hidden from the outside world. The private members implement the OOP concept of data hiding. The private members of a class can be used only by member functions (and friends) of the class in which it is declared.

Concept: Using Private and Public Visibility Modes, Default Visibility Mode (Private)
  Is there an error in this question or solution?
Advertisement Remove all ads
Advertisement Remove all ads
Advertisement Remove all ads
Share
Notifications

View all notifications


      Forgot password?
View in app×