What do you mean by public, private, protected and friendly?

Answer Posted / diya verma

Public : it is access modifier and also known as visibility mode.It is used to declare public members in a class.It is also used in inherit the derived class which shows public member of base class with the help of object of derived class in global scope.The public member can be accessed outside the class.

Private:It is access modifier and also known as visibility mode.It is used to accessed inside the class I.e the member of class is private.
1. All the public member will be private member of child class.
2.All the protected member will be private member of child class.
3.Private member can't be inherit.

Protected:It is access modifier and also known as visibility mode.
1.All public members will be protected member of child class.
2.All the protected member will be protected member of child class.
3.Private member can't be inherit.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does polymorphism work?

635


Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.

1780


2. Give the different notations for the class.\

1584


Why do pointers exist?

655


What is abstraction in oop?

631






What is overriding in oop?

548


How to use CMutex, CSemaphore in VC++ MFC

4326


Give two or more real cenario of virtual function and vertual object

1851


What is class in oop with example?

616


Plese get me a perfect C++ program for railway/airway reservation with all details.

3427


What is the difference between procedural programming and oops?

550


Can you explain polymorphism?

578


What is the point of oop?

648


What is encapsulation oop?

574


What is abstraction oop?

622