It means the member is only accessible to the class itself, and to friends of the class.
Protected members are the same as private members but are also accessible to derived classes.
Public members are fully accessible.
Base class should no knowledge about derived classes. The "private" modifier on a data member means private to the class which defined it. Base class cannot directly reference/access the private data member of the derived class, and the derived classes cannot access the private data member defined in the base class. Either way the accessing the private data member should be done via properties or getters
A private member can only be accessed by other methods of the same class, while a public member can be accessed by methods of any class or by non class code.
A private member of a class can only be accessed by methods of that class. A protected member of a class can only be accessed by methods of that class and by methods of a derived class of that class.
Public, protected and private inheritance determine how the public and protected base class members are inherited by the derived class. Private members are never inherited and are therefore unaffected by the type of inheritance (they remain private to the base class). The following table summarises how inheritance affects accessibility of base class members with respect to the derived class: public inheritanceprotected inheritanceprivate inheritancepublic member of base classpublic member of derived classprotected member of derived classprivate member of derived classprotected member of base classprotected member of derived classprotected member of derived classprivate member of derived classprivate member of base classprivate member of base classprivate member of base classprivate member of base class Note that accessibility to individual public and protected base class members can be overridden within the derived class, regardless of the type of inheritance specified.
public members can be accessed from outside the class they were declared in, private members can only be accessed from within the class they were declared in. Private members are commonly manipulated through get/set methods, which allows for greater encapsulation and hides the implementation from the calling function. Example: class sampleClass{ private: int private_member; public: int public_member; public: void setPrivateMember(int x){private_member = x;}; // private members can be accessed from within the class that they are declared in public: int getPrivateMember(){return private_member;}; }; int main() { sampleClass A; A.public_member = 5; // Perfectly legal A.private_member = 7; // Syntax error, this will not compile A.setPrivateMember(7); // Legal cout << A.getPrivateMember(); // Legal return 0; }
this is the reason for security purpose
The private specifier states that the member can only be accessed by the containing class, and not by any derived class, nor by any other code outside of a class.
Derived classes only inherit the protected and public members of their base classes. Private member functions cannot be inherited by a derived class.
The rank of a military member, most likely Army e-1
Private construction prevents objects from the class from being instantiated other than via a static member function of the class, a friend function or a friend class.
The private keyword is used to ensure that no other classes will be able to access (view or modify) that class member.
Whne you define a member with reserved word private, you hide it from other part of program except that class where it was defined.