C++
Programming and Technical
Programming
Technical
What is public, protected, and private?
Read Solution (Total 2)
-
- 1. Public
Public, means all the class members declared under public,it provides anywhere access.
2. Private
Private keyword, means that no one can access the class members outside that class. If someone tries to access the private member, they will get a compile time error. By default class variables and member functions are private.
3. Protected
Protected, is similar to private. It provides anywhere access within the specific limit. it makes class member inaccessible outside the class. But they can be accessed by any subclass of that class.
- 10 years agoHelpfull: Yes(1) No(0)
- The keywords public, private, and protected are called access specifiers.
The keyword is used to expose data members and methods to any and all users of a class. It is a mechanism to allow for a public interface.
The keyword is used to limit exposure of class data to members and member functions of a derived class. It provides for read-only access.
The keyword is used to restrict use of a data member or member function to a class itself. - 6 years agoHelpfull: Yes(0) No(0)
C++ Other Question