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

Can c++ be faster than c?

604


Can a class be static in c++?

573


Which compiler does turbo c++ use?

609


Is linux written in c or c++?

559


What is the use of setprecision in c++?

548






What does std :: flush do?

692


How is new() different from malloc()?

635


What is singleton class in c++?

596


Does improper inheritance have a potential to wreck a project?

634


Explain explicit container.

633


Write a c program for binary addition of two 8 bit numbers.

3668


Does c++ support exception handling?

600


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

670


What does the following do: for(;;) ; a) Illegal b) Loops forever c) Ignored by compiler...not illegal

704


Write a program in c++ to print the numbers from n to n2 except 5 and its multiples

2041