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

Answer Posted / manjusinga

public is used for global access that is its scope is not
only within the class but also outside the class.

private is used only in the class class in which it is
defined.It cannot be accessible by its derived members.

protected is used within the class in which it is defined
and derived members of it can also access it.

Is This Answer Correct ?    133 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between struct and class in terms of access modifier.

686


What is the difference between global variables and local variable

524


Is it possible to provide default values while overloading a binary operator?

759


What is the best book for c++ beginners?

562


Why the usage of pointers in C++ is not recommended ?

890






what Is DCS ? what i will get benefit when i did?

1827


On throwing an exception by the animal constructor in p = new animalq, can memory leak occur?

669


Why do we use setw in c++?

633


What is the best way to declare and define global variables?

690


What is a Default constructor?

903


Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?

734


How are the features of c++ different from c?

580


How can I learn dev c++ programming?

555


What is the use of 'using' declaration in c++?

617


What is malloc in c++?

545