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

Answers were Sorted based on User's Feedback



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

Answer / koushik k reddy

Private:
It cannot be accessed by object and cannot be inherited, will be used only by the member functions of the class
Protected:
It cannot be accessed by the object and used by the member functions of the class can be inherited to first level of inheritance
Public:
It can be accessed by the objects and can be inherited to any level

Is This Answer Correct ?    1 Yes 0 No

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

Answer / kalpana.y


Private is used for intialization of variables
eg:
int p,r;
public is used for function name
eg:
void display();
protected is used for void main()

eg:
void main()
class c;

Is This Answer Correct ?    24 Yes 86 No

Post New Answer

More C++ General Interview Questions

Write a code/algo to find the frequency of each element in an array?

0 Answers   Axtria,


Which format specifier is used for printing a pointer value?

0 Answers  


How a pointer differs from a reference?

0 Answers  


How do you establish a has-a relationship?

0 Answers  


Explain 'this' pointer and what would happen if a pointer is deleted twice?

0 Answers   Genpact,






How is new() different from malloc()?

0 Answers  


What are guid? Why does com need guids?

0 Answers  


Which bit wise operator is suitable for turning off a particular bit in a number?

0 Answers  


What are c++ stream classes?

0 Answers  


What is const pointer and const reference?

0 Answers  


How do you invoke a base member function from a derived class in which you have not overridden that function?

0 Answers  


How is computer programming useful in real life?

0 Answers  


Categories