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

Why we use #include iostream in c++?

989


What relational operators if statements in c++?

1113


Arrange Doubly linked list in the ascending order of its integral value and replace integer 5 with 7?

4070


In c++, what is the difference between method overloading and method overriding?

1073


What is while loops?

994


How come you find out if a linked-list is a cycle or not?

988


Write a single instruction that will store an EVEN random integer between 54 and 212 inclusive in the variable myran. (NOTE only generate EVEN random numbers)

1877


Why is c++ difficult?

988


What is dynamic and static typing?

1133


Can notepad ++ run c++?

1003


What is a sequence in c++?

959


What are multiple inheritances (virtual inheritance)?

1020


What is data type in c++?

967


What are default parameters? How are they evaluated in c++ function?

1128


How to declare a function pointer?

952