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

What are the manipulators in c++?

547


Define a constructor?

590


What is a lambda function c++?

553


What is setbase c++?

625


What is #include cmath?

663






What is pointer -to-members in C++? Give their syntax?

597


Write a Program for dynamically intialize a 2 dimentional array. Eg:5x20, accept strings and check for vowels and display the no.finally free the space allocated .

680


What is decltype c++?

559


What are the benefits of c++?

569


Can turbo c++ run c program?

631


What is double in c++?

561


What is the basic of c++?

601


Explain unexpected() function?

584


How would you use the functions sin(), pow(), sqrt()?

742


What is a modifier in c++?

634