by Dinesh Thakur Category: Classes in C++

Access Modifiers :- These are also Called as Access Visibility Controls  means they defined where a method and Data Member of class will be used either inside a  class ,outside a class ,in inherited class or in main Method They Tells us the Scope of Methods where they would be used Various types of Access Modifiers  are as follows:-

 1) Public Access: - Public Access modifiers Specifies that data Members and Member Functions those are declared as public will be visible in entire class in which they are defined.  Public Modifier is used when we wants to use the method any where either in the class or from outside the class. The Variables or methods those are declared as public are accessed in any where , Means in any Class which is outside from our main program or in the inherited class or  in the class that is outside from our own class where the method or variables are declared.

 

2) Protected Access:- The Methods those are declared as Protected Access modifiers are Accessible to Only in the Sub Classes but not in the Main Program , This is the Most important Access Modifiers which is used for Making a Data or Member Function as he may only be Accessible to a Class which derives it but it doesn’t allows a user to Access the data which is declared as outside from Program Means Methods those are Declared as Protected are Never be Accessible to Another Class The Protected will be Accessible to Only Sub Class and but not in your Main Program.

 

3) Private Access:- The Methods or variables those are declared as private Access modifiers are not would be not Accessed outside from the class or in inherited Class or the Subclass will not be able to use the Methods those are declared as Private they are Visible only in same class where they are declared. By default all the Data Members and Member Functions is Private, if we never specifies any Access Modifier in front of the Member and Data Members Functions.

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content





Popular Article