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

Answer Posted / krishnachaitanya narne adeesh

Public data is used to access from any where in the program
means any class or any member function can utilize those
variables and member functions.

Where as Private data will not give access to any other
classes and also for derived classes it use those variables
only on particular class only.

Here Protected is similar to Private but difference is just
it gave access to its derived classes also. This is also
opposite to Public.

Is This Answer Correct ?    46 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

C is to C++ as 1 is to a) What the heck b) 2 c) 10

637


How would you differentiate between a pre and post increment operators while overloading?

652


What is increment operator in c++?

560


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

603


What is the difference between structures and unions?

580






To which numbering system can the binary number 1101100100111100 be easily converted to?

608


Explain stack & heap objects?

628


Which is not an ANSII C++ function a) sin() b) tmpnam() c) kbhit()

1005


Why was c++ made?

652


What is the main use of c++?

551


What is constructor c++?

668


what is a reference variable in C++?

662


Can java be faster than c++?

669


What is an incomplete type in c++?

762


What are the restrictions apply to constructors and destructors?

641