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 / swetcha

We use these keywords to specify access levels for member
variables, or for member functions (methods).

.Public variables, are variables that are visible to all
classes.

.Private variables, are variables that are visible only to
the class to which they belong.

.Protected variables, are variables that are visible only
to the class to which they belong, and any subclasses.


Deciding when to use private, protected, or public
variables is sometimes tricky. You need to think whether or
not an external object (or program), actually needs direct
access to the information. If you do want other objects to
access internal data, but wish to control it, you would
make it either private or protected, but provide functions
which can manipulate the data in a controlled way.

Is This Answer Correct ?    172 Yes 22 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is enum c++?

1239


Evaluate !(1&&1||1&&0) a) Error b) False c) True

1208


How many different levels of pointers are there?

1211


Is it possible to pass an object of the same class in place of object reference to the copy constructor?

1046


what is upcasting in C++?

1187


What are the four partitions in which c++ compiler divides the ram?

1236


What is name hiding in c++?

1158


What is object in c++ wikipedia?

1001


How many static variables are created if you put one static member into a template class definition?

1047


Why struct is used in c++?

1126


Can you use the function fprintf() to display the output on the screen?

1247


When is the destructor called?

1032


Define Virtual function in C++.

1095


If dog is a friend of boy and boy is a friend of house, is dog a friend of house?

1008


What are manipulators used for?

1097