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 object in c++ wikipedia?

1011


What is setw manipulator in c++?

1085


What is encapsulation in c++?

1299


What is constructor in C++?

1090


Does improper inheritance have a potential to wreck a project?

1160


What is the word you will use when defining a function in base class to allow this function to be a polimorphic function?

1181


When to use “const” reference arguments in a function?

1077


Which field is used in c++?

1110


Is it possible for a member function to delete the pointer, named this?

1169


What is vector pair in c++?

1233


What is tellg () in c++?

1314


Is set c++?

1008


How are the features of c++ different from c?

1107


What are formatting flags in ios class?

1307


What do you mean by funtion prototype?

1084