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

Will a C compiler always compile C++ code a) Yes b) No c) Only optimized compilers

595


Define a nested class.

598


What will the line of code below print out and why?

312


Is it legal in c++ to overload operator++ so that it decrements a value in your class?

596


How can you specify a class in C++?

776






How can I learn dev c++ programming?

553


Which is the best c++ compiler for beginners?

548


What is the use of endl in c++ give an example?

597


What is null c++?

570


What is a container class? What are the types of container classes in c++?

663


Can c++ be faster than c?

580


Differentiate between C and C++.

697


Explain queue. How it can be implemented?

658


Write about a nested class and mention its use?

609


How do I get good at c++ programming?

580