Which feature is supported by a structure in C++ but is not supported by a traditional structure in C?
Options
- A. Member functions
- B. Integer data members
- C. Character data members
- D. More than one of the above
- E. None of the above
Quiz Practice:
A. Member functions
Answer: (A) Member functions
C++ structures can contain member functions along with data members.
For example:
struct Student {
int marks;
void display() { cout << marks; }
};
A traditional C structure primarily groups data members and does not support member functions in the C++ class-like sense.
Therefore, member functions are an important C++ feature that can be used inside structures.