In C++, what does a class hold?
2023
In C++, what does a class hold?
- A.
Array
- B.
Data
- C.
Data and functions
- D.
More than one of the above
- E.
None of the above
Attempted by 695 students.
Show answer & explanation
Correct answer: C
In C++, a class is a user-defined data type that can hold both data members (variables) and member functions (methods). Data members store the state of an object, while member functions define the behavior. This combination allows classes to encapsulate data and operations together, forming the basis of object-oriented programming.