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

What is the use of setprecision in c++?

0 Answers  


What are templates? where we should use it?

2 Answers   Alcatel,


What does namespace mean in c++?

0 Answers  


What it is and how it might be called (2 methods).

0 Answers  


How would you stop a class from class from being derived or inherited?The constructer should not be Private,as object instantiation should be allowed.

15 Answers   Satyam,






What is implicit conversion/coercion in c++?

1 Answers  


What is the maximum value of a unsigned char a) 255 b) 256 c) 128

0 Answers  


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

4 Answers   Webyog,


Why do we use pointers in c++?

0 Answers  


write the prime no program in c++?

16 Answers  


Explain how an exception handler is defined and invoked in a Program.

0 Answers  


Which is better c++ or java?

0 Answers  


Categories