Which statement about a pure virtual function in C++ is correct?

Options

  • A. Every virtual function must be pure virtual
  • B. A pure virtual function can only be declared in a derived class
  • C. A pure virtual function can help define an interface for derived classes
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. A pure virtual function can help define an interface for derived classes

Detailed Explanation

Correct Answer: Option C

Explanation:
Pure virtual functions are commonly used to define interfaces in C++. They require concrete derived classes to provide implementations before objects of those classes can be created. Ordinary virtual functions do not have to be pure virtual, and pure virtual functions are commonly declared in base classes.