Explain the different access specifiers for the class member in c++.



Explain the different access specifiers for the class member in c++...

Answer / Isha Vishnoi

In C++, there are three different access specifiers for class members: public (default), private, and protected. Public members can be accessed from anywhere including within the class, outside the class, or even by a derived class. Private members can only be accessed from within the same class they were declared in, but not from outside the class or derived classes. Protected members are similar to private members but can also be accessed by a derived class.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

Give 10 points of differences between C & C++.

1 Answers   HCL,


Why is main an int?

1 Answers  


What is std::move?

1 Answers  


Why namespace is used in c++?

1 Answers  


What are the comments in c++?

1 Answers  


Write a program in c++ to print the numbers from n to n2 except 5 and its multiples

1 Answers   Cankaya University,


Where are setjmp and longjmp used in c++?

1 Answers  


Write a program to calculate the BMI of a person using the formula BMI = weight/height2.

2 Answers  


advantages and disadvantages of using Borland C++ / version 5.

1 Answers  


What is Pure Virtual Function? Why and when it is used ?

10 Answers   Lucent, Sona,


Is c the same as c++?

1 Answers  


What is enum c++?

1 Answers  


Categories