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 |
How do I run c++?
What is an ABC: an "Abstract Base Class"?
Is there any difference between int [] a and int a [] in c++?
What do you mean by a template?
What is c++ programming language?
What is set in c++?
What's the most powerful programming language?
Explain method of creating object in C++ ?
What is the average salary of a c++ programmer?
What is the difference between public, private, protected inheritance?
Write a C++ Program to Generate Random Numbers between 0 and 100
In which memory a class gets stored(in heap /in stack)? And why??