What are the differences between public, private, and
protected access?
Answers were Sorted based on User's Feedback
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 |
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 |
Write a code/algo to find the frequency of each element in an array?
Which format specifier is used for printing a pointer value?
How a pointer differs from a reference?
How do you establish a has-a relationship?
Explain 'this' pointer and what would happen if a pointer is deleted twice?
How is new() different from malloc()?
What are guid? Why does com need guids?
Which bit wise operator is suitable for turning off a particular bit in a number?
What are c++ stream classes?
What is const pointer and const reference?
How do you invoke a base member function from a derived class in which you have not overridden that function?
How is computer programming useful in real life?