What is default access specifier for data members or member functions declared within a class without any specifier, in C++?
A. Private
B. Protected
C. Public
D. Depends on compiler
I got this question in my homework.
This intriguing question originated from Classes in chapter OOPs Concept & Features of Object Oriented Programming
Right answer is A. Private
Easiest explanation – The data members and member functions are Private by default in C++ classes, if none of the access specifier is used. It is actually made to increase the privacy of data.