Which statement correctly describes member functions in C++ structures and classes?

Options

  • A. Only classes can contain member functions
  • B. Only structures can contain member functions
  • C. Both structures and classes can contain member functions
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. Both structures and classes can contain member functions

Detailed Explanation

Correct Answer: Option C

Explanation: Both struct and class can define member functions. For example, a struct can contain a function that calculates and returns a value. Access to members follows the applicable access specifier and default access rules.