Which of the following is correct in C++?

Which of the following is correct in C++?
A. Classes cannot have protected data members
B. Structures can have member functions
C. Class members are public by default
D. Structure members are private by default
 
Answer: b
Explanation: Though C does not allows member functions in structures but C++ allows structures to have member functions. Members of structures are public by default and those of classes are private by default. Classes can have protected data members.
 

Tìm kiếm

Back
Top