Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What are the differences between public, private, and
protected access?

Answer Posted / it

Public is used for global access so its scope is not only
within the class but also outside the class. For example
public variables will be visible to all classes and any
class or member function can utilize those variables and
member functions.

Private is used only in the class in which it is defined.
It cannot be accessible by its derived members. So private
variables will be visible only to the class to which they
belong and it will not give access to any other classes.
Public and protected members will become private in derived
class.

Protected is used within the class in which it is defined
and derived members of it can also access it. So protected
variables will be visible only to the class to which they
belong and it gave access to its derived classes also.

Is This Answer Correct ?    17 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between new() and malloc()?

2223


Can I uninstall microsoft c++ redistributable?

1187


Inline parameters : What does the compiler do with the parameters of inline function, that can be evaluated in runtime ?

2587


How many types of modularization are there in c++?

1120


What is the this pointer?

1165


What are the advantages of c++ over c?

1134


Explain the volatile and mutable keywords.

1115


What is encapsulation in c++ with example?

1041


Refer to a name of class or function that is defined within a namespace?

1156


Which programming language's unsatisfactory performance led to the discovery of c++?

1396


What is the keyword auto for?

1087


True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends

2437


How the keyword struct is different from the keyword class in c++?

1087


What is the array and initializing arrays in c++?

1074


What is a string example?

1146