[WEBINAR] The New Normal: Dealing with the Reality of an Unsecure World


Definition - What does Private mean?

Private is a keyword that specifies access level and provides programmers with some control over which variables and methods are hidden in a class. Variables and methods defined with the private keyword may be accessed only by other methods within the class and cannot be accessed by derived classes.

The private keyword is used in most object-oriented programming (OOP) languages, including C++, C# and Java.

Techopedia explains Private

The private access specifier is mostly used for encapsulation, which refers to variables or methods hidden from the outside world. This means that private variables and methods are tightly bound to a class and only available within the class scope. Private data members are usually accessed through special methods known as setters. The compiler returns an error message if a programmer attempts to access a private variable or method from outside its class.

C++ enables the use of friend functions and classes to access a private variable or method. If a class is declared a friend to another class (through adding a line of code in the latter class stating that the former class is its friend via the friend keyword), then the former class may access private variables and methods from the latter class. Additionally, if class A is a friend to class B, then B is not implicitly a friend to A. Furthermore, friendship is not transitive. For example, if A is a friend to B, and B is a friend to C, then A is not implicitly a friend to C.

Techopedia Deals

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
"Techopedia" on Twitter

Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Free Whitepaper: The Path to Hybrid Cloud
Free Whitepaper: The Path to Hybrid Cloud:
The Path to Hybrid Cloud: Intelligent Bursting To Amazon Web Services & Microsoft Azure
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.