Access specifiers are keywords used to identify access rights for the data and member functions of the class. These specifiers are used to denote the "power" of members(variables or methods) when they are accessed
from outside the class. Inside the class all members are "public", which means that all the methods have an access to them. If none of the access specifier is given the default specifier is "private".
A member of a class can be accessed from
a) Within a class
b) In the sub class
c) From a class object.
There are three main types of access specifiers in C++ programming language:
- Private : A private member within a class denotes that only members of the same class have accessibility. The private member is inaccessible from outside the class. We can access the private members of the class from inside the xlass but not from an object or a sub class.
- Public : Public members are accessible from outside the class. Such members are available to all the child classes and objects of the class. A sub class can use the "public" members of the base class as its own whereas a class object can access them using the "object.member" syntax.
- Protected : A protected access specifier is a combination of both "private" and "public" specifier.A protected member is accessible from a child class just like a public member but when it comes to accessing from an object a protected member acts like a private member and refuses to be accessed. The protected specifier comes into picture only when there is inheritance. If there is no need to inherit a class, the public and private specifiers are sufficient to describle the accessibility.
Look at the following table for a more clear understanding.
Specifier | Own Class | Sub Class | Object Of The Class |
---|---|---|---|
Private | Accessible | Not Accessible | Not Accessible |
Public | Accessible | Accessible | Accessible |
Protected | Accessible | Accessible | Not Accessible |
A good deal doesn't usually mean the most affordable one. A leasing company can save you a lot of money and not just when it comes to leasing costs. You may also be charged at the end of your lease for excessive mileage, damages, and unusual wear-and-tear.
ReplyDeletemy blog Business Car Leasing
Once your wound has started to heal, a scab may begin to form and new skin may start to grow.
ReplyDeleteBecoming more active and getting out and about in the fresh air will do wonders
for your complexion. Organic elements and serums are being discovered and tested, showing amazing results in treating acne
and preventing acne scarring.
Feel free to surf to my webpage ... How To Remove Skin Tags